about summary refs log tree commit diff
path: root/src/state/models/feed-view.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-10-04 14:22:20 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-10-04 14:22:20 -0500
commitf5c4a97eaff92e37f18562f1cb6c4fb209c4bc09 (patch)
tree5950c76b31f30e0e8c2b747efd1aa776fcfa14f2 /src/state/models/feed-view.ts
parent5631c2d2e66f76f751370ab218505fbba96d0e93 (diff)
downloadvoidsky-f5c4a97eaff92e37f18562f1cb6c4fb209c4bc09.tar.zst
Add firehose view to home screen
Diffstat (limited to 'src/state/models/feed-view.ts')
-rw-r--r--src/state/models/feed-view.ts22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts
index 4b009bff8..3d618f91e 100644
--- a/src/state/models/feed-view.ts
+++ b/src/state/models/feed-view.ts
@@ -36,14 +36,14 @@ export class FeedItemModel implements GetHomeFeed.FeedItem {
   constructor(
     public rootStore: RootStoreModel,
     reactKey: string,
-    v: GetHomeFeed.FeedItem,
+    v: GetHomeFeed.FeedItem | GetAuthorFeed.FeedItem,
   ) {
     makeAutoObservable(this, {rootStore: false})
     this._reactKey = reactKey
     this.copy(v)
   }
 
-  copy(v: GetHomeFeed.FeedItem) {
+  copy(v: GetHomeFeed.FeedItem | GetAuthorFeed.FeedItem) {
     this.cursor = v.cursor
     this.uri = v.uri
     this.author = v.author
@@ -309,25 +309,28 @@ export class FeedModel {
     }
   }
 
-  private _replaceAll(res: GetHomeFeed.Response) {
+  private _replaceAll(res: GetHomeFeed.Response | GetAuthorFeed.Response) {
     this.feed.length = 0
     this.hasReachedEnd = false
     this._appendAll(res)
   }
 
-  private _appendAll(res: GetHomeFeed.Response) {
+  private _appendAll(res: GetHomeFeed.Response | GetAuthorFeed.Response) {
     let counter = this.feed.length
     for (const item of res.data.feed) {
       this._append(counter++, item)
     }
   }
 
-  private _append(keyId: number, item: GetHomeFeed.FeedItem) {
+  private _append(
+    keyId: number,
+    item: GetHomeFeed.FeedItem | GetAuthorFeed.FeedItem,
+  ) {
     // TODO: validate .record
     this.feed.push(new FeedItemModel(this.rootStore, `item-${keyId}`, item))
   }
 
-  private _prependAll(res: GetHomeFeed.Response) {
+  private _prependAll(res: GetHomeFeed.Response | GetAuthorFeed.Response) {
     let counter = this.feed.length
     for (const item of res.data.feed) {
       if (this.feed.find(item2 => item2.uri === item.uri)) {
@@ -337,12 +340,15 @@ export class FeedModel {
     }
   }
 
-  private _prepend(keyId: number, item: GetHomeFeed.FeedItem) {
+  private _prepend(
+    keyId: number,
+    item: GetHomeFeed.FeedItem | GetAuthorFeed.FeedItem,
+  ) {
     // TODO: validate .record
     this.feed.unshift(new FeedItemModel(this.rootStore, `item-${keyId}`, item))
   }
 
-  private _updateAll(res: GetHomeFeed.Response) {
+  private _updateAll(res: GetHomeFeed.Response | GetAuthorFeed.Response) {
     for (const item of res.data.feed) {
       const existingItem = this.feed.find(
         // this find function has a key subtley- the indexedAt comparison