forked from fedi/mastodon
Fix infinite scrolling breaking after navigation
This commit is contained in:
parent
4aa5ebe591
commit
c50256d25c
|
@ -70,13 +70,13 @@ export function refreshTimeline(timeline, id = null) {
|
||||||
|
|
||||||
const ids = getState().getIn(['timelines', timeline, 'items'], Immutable.List());
|
const ids = getState().getIn(['timelines', timeline, 'items'], Immutable.List());
|
||||||
const newestId = ids.size > 0 ? ids.first() : null;
|
const newestId = ids.size > 0 ? ids.first() : null;
|
||||||
const params = getState().getIn(['timelines', timeline, 'params'], {});
|
let params = getState().getIn(['timelines', timeline, 'params'], {});
|
||||||
const path = getState().getIn(['timelines', timeline, 'path'])(id);
|
const path = getState().getIn(['timelines', timeline, 'path'])(id);
|
||||||
|
|
||||||
let skipLoading = false;
|
let skipLoading = false;
|
||||||
|
|
||||||
if (newestId !== null && getState().getIn(['timelines', timeline, 'loaded']) && (id === null || getState().getIn(['timelines', timeline, 'id']) === id)) {
|
if (newestId !== null && getState().getIn(['timelines', timeline, 'loaded']) && (id === null || getState().getIn(['timelines', timeline, 'id']) === id)) {
|
||||||
params.since_id = newestId;
|
params = { ...params, since_id: newestId };
|
||||||
skipLoading = true;
|
skipLoading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,12 @@ const normalizeNotifications = (state, notifications, next) => {
|
||||||
items = items.set(i, notificationToMap(n));
|
items = items.set(i, notificationToMap(n));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (state.get('next') === null) {
|
||||||
|
state = state.set('next', next);
|
||||||
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
.update('items', list => loaded ? list.unshift(...items) : list.push(...items))
|
.update('items', list => loaded ? list.unshift(...items) : list.push(...items))
|
||||||
.set('next', next)
|
|
||||||
.set('loaded', true)
|
.set('loaded', true)
|
||||||
.set('isLoading', false);
|
.set('isLoading', false);
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,7 +101,10 @@ const normalizeTimeline = (state, timeline, statuses, next) => {
|
||||||
|
|
||||||
state = state.setIn([timeline, 'loaded'], true);
|
state = state.setIn([timeline, 'loaded'], true);
|
||||||
state = state.setIn([timeline, 'isLoading'], false);
|
state = state.setIn([timeline, 'isLoading'], false);
|
||||||
state = state.setIn([timeline, 'next'], next);
|
|
||||||
|
if (state.getIn([timeline, 'next']) === null) {
|
||||||
|
state = state.setIn([timeline, 'next'], next);
|
||||||
|
}
|
||||||
|
|
||||||
return state.updateIn([timeline, 'items'], Immutable.List(), list => (loaded ? list.unshift(...ids) : ids));
|
return state.updateIn([timeline, 'items'], Immutable.List(), list => (loaded ? list.unshift(...ids) : ids));
|
||||||
};
|
};
|
||||||
|
@ -237,6 +240,7 @@ const resetTimeline = (state, timeline, id) => {
|
||||||
.set('id', id)
|
.set('id', id)
|
||||||
.set('isLoading', true)
|
.set('isLoading', true)
|
||||||
.set('loaded', false)
|
.set('loaded', false)
|
||||||
|
.set('next', null)
|
||||||
.update('items', list => list.clear()));
|
.update('items', list => list.clear()));
|
||||||
} else {
|
} else {
|
||||||
state = state.setIn([timeline, 'isLoading'], true);
|
state = state.setIn([timeline, 'isLoading'], true);
|
||||||
|
|
Loading…
Reference in a new issue