Remember scroll position when navigating back, do not needlessly reload

entire timelines (only fetch since last known ID). Side effect: account
timelines no longer update in real-time
This commit is contained in:
Eugen Rochko 2016-10-18 23:06:28 +02:00
parent 1d2175f73c
commit 8698cd3281
10 changed files with 76 additions and 20 deletions

View file

@ -45,7 +45,16 @@ export function refreshTimeline(timeline) {
return function (dispatch, getState) {
dispatch(refreshTimelineRequest(timeline));
api(getState).get(`/api/v1/statuses/${timeline}`).then(function (response) {
const ids = getState().getIn(['timelines', timeline]);
const newestId = ids.size > 0 ? ids.first() : null;
let params = '';
if (newestId !== null) {
params = `?since_id=${newestId}`;
}
api(getState).get(`/api/v1/statuses/${timeline}${params}`).then(function (response) {
dispatch(refreshTimelineSuccess(timeline, response.data));
}).catch(function (error) {
dispatch(refreshTimelineFail(timeline, error));