]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix potentially missing statuses when reconnecting to websocket
authorClaire <claire.github-309c@sitedethib.com>
Thu, 7 Apr 2022 14:08:17 +0000 (16:08 +0200)
committerClaire <claire.github-309c@sitedethib.com>
Fri, 8 Apr 2022 18:02:49 +0000 (20:02 +0200)
Port ebe01ea194104b14af6cd6abe6d20637f1a3e140 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/actions/timelines.js
app/javascript/flavours/glitch/reducers/timelines.js

index 24cc0d63fdf50094de9559b4cf501211792af9f3..71d5fff9797e081c8d5cbc19b4f3dd058b3eceb8 100644 (file)
@@ -199,6 +199,7 @@ export function connectTimeline(timeline) {
   return {
     type: TIMELINE_CONNECT,
     timeline,
+    usePendingItems: preferPendingItems,
   };
 };
 
index 29e02a86408d73e6942ddeb2e1b687fa9cc8c578..afd9d12cb985a003c7a3bb80c1fb1f34b7c9f264 100644 (file)
@@ -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,