about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-12-17 11:09:06 +0000
committerGitHub <noreply@github.com>2024-12-17 11:09:06 +0000
commit31d2aa6716007871d50892be8b866085309ae92c (patch)
tree704a6fc26815603f9399cc61c3971a5862c96596 /src
parent20d4266e2f8ef82b6ed1244fd929dd07c01486dc (diff)
downloadvoidsky-31d2aa6716007871d50892be8b866085309ae92c.tar.zst
Refetch empty feed on focus (#7139)
Diffstat (limited to 'src')
-rw-r--r--src/view/com/posts/PostFeed.tsx19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/view/com/posts/PostFeed.tsx b/src/view/com/posts/PostFeed.tsx
index 674670337..55d7ba053 100644
--- a/src/view/com/posts/PostFeed.tsx
+++ b/src/view/com/posts/PostFeed.tsx
@@ -187,12 +187,16 @@ let PostFeed = ({
     }
     try {
       if (await pollLatest(data.pages[0])) {
-        onHasNew(true)
+        if (isEmpty) {
+          refetch()
+        } else {
+          onHasNew(true)
+        }
       }
     } catch (e) {
       logger.error('Poll latest failed', {feed, message: String(e)})
     }
-  }, [feed, data, isFetching, onHasNew, enabled, disablePoll])
+  }, [feed, data, isFetching, isEmpty, onHasNew, enabled, disablePoll, refetch])
 
   const myDid = currentAccount?.did || ''
   const onPostCreated = React.useCallback(() => {
@@ -220,20 +224,15 @@ let PostFeed = ({
   React.useEffect(() => {
     if (enabled && !disablePoll) {
       const timeSinceFirstLoad = Date.now() - lastFetchRef.current
-      // DISABLED need to check if this is causing random feed refreshes -prf
-      /*if (timeSinceFirstLoad > REFRESH_AFTER) {
-        // do a full refresh
-        scrollElRef?.current?.scrollToOffset({offset: 0, animated: false})
-        queryClient.resetQueries({queryKey: RQKEY(feed)})
-      } else*/ if (
-        timeSinceFirstLoad > CHECK_LATEST_AFTER &&
+      if (
+        (isEmpty || timeSinceFirstLoad > CHECK_LATEST_AFTER) &&
         checkForNewRef.current
       ) {
         // check for new on enable (aka on focus)
         checkForNewRef.current()
       }
     }
-  }, [enabled, disablePoll, feed, queryClient, scrollElRef])
+  }, [enabled, disablePoll, feed, queryClient, scrollElRef, isEmpty])
   React.useEffect(() => {
     let cleanup1: () => void | undefined, cleanup2: () => void | undefined
     const subscription = AppState.addEventListener('change', nextAppState => {