about summary refs log tree commit diff
path: root/src/lib/api/feed
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-12-11 12:58:34 -0800
committerGitHub <noreply@github.com>2023-12-11 12:58:34 -0800
commitb82c5177b9987efe92a642e9619dde604dda3da0 (patch)
treee5b11261b8e97b3a0d015ad09601cd44e0b33ce0 /src/lib/api/feed
parent3d229b5fd6d4f0773f607cf1d6e7b2377c33ccbb (diff)
downloadvoidsky-b82c5177b9987efe92a642e9619dde604dda3da0.tar.zst
Reduce calls to getFeedGenerator and getFeed (#2166)
* Reduce calls to getFeedGenerator by the mergefeed

* Dont run end-of-follows mergefeed requests until actually at the end of the feed

* build AWS container

---------

Co-authored-by: Jake Gold <jake@blueskyweb.xyz>
Diffstat (limited to 'src/lib/api/feed')
-rw-r--r--src/lib/api/feed/merge.ts28
-rw-r--r--src/lib/api/feed/types.ts2
2 files changed, 11 insertions, 19 deletions
diff --git a/src/lib/api/feed/merge.ts b/src/lib/api/feed/merge.ts
index 381159d18..a4391afb2 100644
--- a/src/lib/api/feed/merge.ts
+++ b/src/lib/api/feed/merge.ts
@@ -62,7 +62,7 @@ export class MergeFeedAPI implements FeedAPI {
 
     // always keep following topped up
     if (this.following.numReady < limit) {
-      promises.push(this.following.fetchNext(60))
+      await this.following.fetchNext(60)
     }
 
     // pick the next feeds to sample from
@@ -73,9 +73,13 @@ export class MergeFeedAPI implements FeedAPI {
     }
 
     // top up the feeds
-    for (const feed of feeds) {
-      if (feed.numReady < 5) {
-        promises.push(feed.fetchNext(10))
+    const outOfFollows =
+      !this.following.hasMore && this.following.numReady < limit
+    if (this.params.mergeFeedEnabled || outOfFollows) {
+      for (const feed of feeds) {
+        if (feed.numReady < 5) {
+          promises.push(feed.fetchNext(10))
+        }
       }
     }
 
@@ -216,22 +220,10 @@ class MergeFeedSource_Custom extends MergeFeedSource {
     super(feedTuners)
     this.sourceInfo = {
       $type: 'reasonFeedSource',
-      displayName: feedUri.split('/').pop() || '',
-      uri: feedUriToHref(feedUri),
+      uri: feedUri,
+      href: feedUriToHref(feedUri),
     }
     this.minDate = new Date(Date.now() - POST_AGE_CUTOFF)
-    getAgent()
-      .app.bsky.feed.getFeedGenerator({
-        feed: feedUri,
-      })
-      .then(
-        res => {
-          if (this.sourceInfo) {
-            this.sourceInfo.displayName = res.data.view.displayName
-          }
-        },
-        _err => {},
-      )
   }
 
   protected async _getFeed(
diff --git a/src/lib/api/feed/types.ts b/src/lib/api/feed/types.ts
index 5d2a90c1d..abc6511ba 100644
--- a/src/lib/api/feed/types.ts
+++ b/src/lib/api/feed/types.ts
@@ -19,7 +19,7 @@ export interface FeedAPI {
 export interface ReasonFeedSource {
   $type: 'reasonFeedSource'
   uri: string
-  displayName: string
+  href: string
 }
 
 export function isReasonFeedSource(v: unknown): v is ReasonFeedSource {