about summary refs log tree commit diff
path: root/src/state/models/feeds/posts.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-05-02 23:06:55 -0500
committerGitHub <noreply@github.com>2023-05-02 23:06:55 -0500
commit6f1c4ec9a9b5b7d0b4b67f3bc7c3af6810da5001 (patch)
tree80401e47119aa52ac188a290d140ae56686162bb /src/state/models/feeds/posts.ts
parent95f8360d19938d00aaf9036a76616a7b82093703 (diff)
downloadvoidsky-6f1c4ec9a9b5b7d0b4b67f3bc7c3af6810da5001.tar.zst
[APP-549] Language controls for Whats Hot (#563)
* Add a content-language preference control

* Update whats hot to only show the selected languages and to refresh on lang pref changes

* Fix lint

* Fix tests

* Add missing accessibility role
Diffstat (limited to 'src/state/models/feeds/posts.ts')
-rw-r--r--src/state/models/feeds/posts.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts
index 62047acba..44cec3af7 100644
--- a/src/state/models/feeds/posts.ts
+++ b/src/state/models/feeds/posts.ts
@@ -297,6 +297,9 @@ export class PostsFeedModel {
   // used to linearize async modifications to state
   lock = new AwaitLock()
 
+  // used to track if what's hot is coming up empty
+  emptyFetches = 0
+
   // data
   slices: PostsFeedSliceModel[] = []
 
@@ -603,6 +606,9 @@ export class PostsFeedModel {
   ) {
     this.loadMoreCursor = res.data.cursor
     this.hasMore = !!this.loadMoreCursor
+    if (replace) {
+      this.emptyFetches = 0
+    }
 
     this.rootStore.me.follows.hydrateProfiles(
       res.data.feed.map(item => item.post.author),
@@ -625,6 +631,12 @@ export class PostsFeedModel {
       } else {
         this.slices = this.slices.concat(toAppend)
       }
+      if (toAppend.length === 0) {
+        this.emptyFetches++
+        if (this.emptyFetches >= 10) {
+          this.hasMore = false
+        }
+      }
     })
   }