diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-04-07 16:08:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-07 16:08:17 +0200 |
commit | ebe01ea194104b14af6cd6abe6d20637f1a3e140 (patch) | |
tree | fc9577333d2b0a6b798325c249584967119f9171 | |
parent | ce9dcbea32e7212dc19d83bbb7a21afe8756ced0 (diff) |
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
-rw-r--r-- | app/javascript/mastodon/actions/timelines.js | 1 | ||||
-rw-r--r-- | app/javascript/mastodon/reducers/timelines.js | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js index 31ae09e4a..8bbaa104a 100644 --- a/app/javascript/mastodon/actions/timelines.js +++ b/app/javascript/mastodon/actions/timelines.js @@ -184,6 +184,7 @@ export function connectTimeline(timeline) { return { type: TIMELINE_CONNECT, timeline, + usePendingItems: preferPendingItems, }; }; diff --git a/app/javascript/mastodon/reducers/timelines.js b/app/javascript/mastodon/reducers/timelines.js index 53a644e47..d72109e69 100644 --- a/app/javascript/mastodon/reducers/timelines.js +++ b/app/javascript/mastodon/reducers/timelines.js @@ -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, |