mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix potential duplicates in timelines when using slow mode
This commit is contained in:
parent
b59fb28e90
commit
65ad87ce4d
1 changed files with 12 additions and 2 deletions
|
@ -182,11 +182,21 @@ const reconnectTimeline = (state, usePendingItems) => {
|
|||
});
|
||||
};
|
||||
|
||||
const mergePendingItems = (state, timeline) => {
|
||||
return state.update(timeline, initialTimeline, map =>
|
||||
map.update('items', (list) => {
|
||||
const oldItems = list.take(40);
|
||||
const newItems = ImmutableOrderedSet(map.get('pendingItems'));
|
||||
newItems.subtract(oldItems);
|
||||
return newItems.toList().concat(oldItems);
|
||||
}).set('pendingItems', ImmutableList()).set('unread', 0)
|
||||
);
|
||||
};
|
||||
|
||||
export default function timelines(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case TIMELINE_LOAD_PENDING:
|
||||
return state.update(action.timeline, initialTimeline, map =>
|
||||
map.update('items', list => map.get('pendingItems').concat(list.take(40))).set('pendingItems', ImmutableList()).set('unread', 0));
|
||||
return mergePendingItems(state, action.timeline);
|
||||
case TIMELINE_EXPAND_REQUEST:
|
||||
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', true));
|
||||
case TIMELINE_EXPAND_FAIL:
|
||||
|
|
Loading…
Reference in a new issue