about summary refs log tree commit diff
path: root/src/state/models/feeds/posts.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-08-22 12:46:49 -0500
committerGitHub <noreply@github.com>2023-08-22 10:46:49 -0700
commit09a445d8042ed1eaee03348065a324575faf4896 (patch)
tree172f089ffdee532079625afabd3fa00259aab952 /src/state/models/feeds/posts.ts
parent88357d5c82aa5afd17a846f34d08b1b30ccff761 (diff)
downloadvoidsky-09a445d8042ed1eaee03348065a324575faf4896.tar.zst
do not thread author media filtered feed (#1253)
Diffstat (limited to 'src/state/models/feeds/posts.ts')
-rw-r--r--src/state/models/feeds/posts.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts
index 6facc27ad..93add8102 100644
--- a/src/state/models/feeds/posts.ts
+++ b/src/state/models/feeds/posts.ts
@@ -11,9 +11,18 @@ import {cleanError} from 'lib/strings/errors'
 import {FeedTuner} from 'lib/api/feed-manip'
 import {PostsFeedSliceModel} from './posts-slice'
 import {track} from 'lib/analytics/analytics'
+import {FeedViewPostsSlice} from 'lib/api/feed-manip'
 
 const PAGE_SIZE = 30
 
+type Options = {
+  /**
+   * Formats the feed in a flat array with no threading of replies, just
+   * top-level posts.
+   */
+  isSimpleFeed?: boolean
+}
+
 type QueryParams =
   | GetTimeline.QueryParams
   | GetAuthorFeed.QueryParams
@@ -35,6 +44,7 @@ export class PostsFeedModel {
   pollCursor: string | undefined
   tuner = new FeedTuner()
   pageSize = PAGE_SIZE
+  options: Options = {}
 
   // used to linearize async modifications to state
   lock = new AwaitLock()
@@ -49,6 +59,7 @@ export class PostsFeedModel {
     public rootStore: RootStoreModel,
     public feedType: 'home' | 'author' | 'custom',
     params: QueryParams,
+    options?: Options,
   ) {
     makeAutoObservable(
       this,
@@ -60,6 +71,7 @@ export class PostsFeedModel {
       {autoBind: true},
     )
     this.params = params
+    this.options = options || {}
   }
 
   get hasContent() {
@@ -354,7 +366,9 @@ export class PostsFeedModel {
       this.rootStore.posts.fromFeedItem(item)
     }
 
-    const slices = this.tuner.tune(res.data.feed, this.feedTuners)
+    const slices = this.options.isSimpleFeed
+      ? res.data.feed.map(item => new FeedViewPostsSlice([item]))
+      : this.tuner.tune(res.data.feed, this.feedTuners)
 
     const toAppend: PostsFeedSliceModel[] = []
     for (const slice of slices) {