Skip to content
Snippets Groups Projects
Unverified Commit ebe01ea1 authored by Claire's avatar Claire Committed by GitHub
Browse files

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
parent ce9dcbea
No related branches found
No related tags found
No related merge requests found
......@@ -184,6 +184,7 @@ export function connectTimeline(timeline) {
return {
type: TIMELINE_CONNECT,
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) {
switch(action.type) {
case TIMELINE_LOAD_PENDING:
......@@ -196,7 +207,7 @@ export default function timelines(state = initialState, action) {
case TIMELINE_SCROLL_TOP:
return updateTop(state, action.timeline, action.top);
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:
return state.update(
action.timeline,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment