mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-27 18:40:12 -05:00
Fix potentially missing statuses when reconnecting to websocket (#17981)
* Fix potentially missing statuses when reconnecting to websocket * Add gap on reconnect rather than maintaining it constantly
This commit is contained in:
parent
ce9dcbea32
commit
ebe01ea194
@ -184,6 +184,7 @@ export function connectTimeline(timeline) {
|
|||||||
return {
|
return {
|
||||||
type: TIMELINE_CONNECT,
|
type: TIMELINE_CONNECT,
|
||||||
timeline,
|
timeline,
|
||||||
|
usePendingItems: preferPendingItems,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,6 +171,17 @@ const updateTop = (state, timeline, top) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const reconnectTimeline = (state, usePendingItems) => {
|
||||||
|
if (state.get('online')) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.withMutations(mMap => {
|
||||||
|
mMap.update(usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items);
|
||||||
|
mMap.set('online', true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export default function timelines(state = initialState, action) {
|
export default function timelines(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case TIMELINE_LOAD_PENDING:
|
case TIMELINE_LOAD_PENDING:
|
||||||
@ -196,7 +207,7 @@ export default function timelines(state = initialState, action) {
|
|||||||
case TIMELINE_SCROLL_TOP:
|
case TIMELINE_SCROLL_TOP:
|
||||||
return updateTop(state, action.timeline, action.top);
|
return updateTop(state, action.timeline, action.top);
|
||||||
case TIMELINE_CONNECT:
|
case TIMELINE_CONNECT:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('online', true));
|
return state.update(action.timeline, initialTimeline, map => reconnectTimeline(map, action.usePendingItems));
|
||||||
case TIMELINE_DISCONNECT:
|
case TIMELINE_DISCONNECT:
|
||||||
return state.update(
|
return state.update(
|
||||||
action.timeline,
|
action.timeline,
|
||||||
|
Loading…
Reference in New Issue
Block a user