mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 07:23:43 +01:00
[Glitch] Fix potentially missing statuses when reconnecting to websocket
Port ebe01ea194
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
ff73d43b35
commit
43aff90d0e
2 changed files with 13 additions and 1 deletions
|
@ -199,6 +199,7 @@ export function connectTimeline(timeline) {
|
|||
return {
|
||||
type: TIMELINE_CONNECT,
|
||||
timeline,
|
||||
usePendingItems: preferPendingItems,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -177,6 +177,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:
|
||||
|
@ -202,7 +213,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,
|
||||
|
|
Loading…
Reference in a new issue