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-04-20 17:16:56 -0500
committerGitHub <noreply@github.com>2023-04-20 17:16:56 -0500
commit22884b53ad4daa2932aa8ed34fc5d5b928f8094d (patch)
tree15319118bfc342d63c9f320b0f2e4f6cc13fc79a /src/state/models/feeds/posts.ts
parent3e78c7101815985241b2631432a023dc8f70d82e (diff)
downloadvoidsky-22884b53ad4daa2932aa8ed34fc5d5b928f8094d.tar.zst
Thread muting [APP-29] (#500)
* Implement thread muting

* Apply filtering on background fetched notifs

* Implement thread-muting tests
Diffstat (limited to 'src/state/models/feeds/posts.ts')
-rw-r--r--src/state/models/feeds/posts.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts
index 38faf658a..58167284d 100644
--- a/src/state/models/feeds/posts.ts
+++ b/src/state/models/feeds/posts.ts
@@ -72,6 +72,17 @@ export class PostsFeedItemModel {
     makeAutoObservable(this, {rootStore: false})
   }
 
+  get rootUri(): string {
+    if (this.reply?.root.uri) {
+      return this.reply.root.uri
+    }
+    return this.post.uri
+  }
+
+  get isThreadMuted() {
+    return this.rootStore.mutedThreads.uris.has(this.rootUri)
+  }
+
   copy(v: FeedViewPost) {
     this.post = v.post
     this.reply = v.reply
@@ -145,6 +156,14 @@ export class PostsFeedItemModel {
     }
   }
 
+  async toggleThreadMute() {
+    if (this.isThreadMuted) {
+      this.rootStore.mutedThreads.uris.delete(this.rootUri)
+    } else {
+      this.rootStore.mutedThreads.uris.add(this.rootUri)
+    }
+  }
+
   async delete() {
     await this.rootStore.agent.deletePost(this.post.uri)
     this.rootStore.emitPostDeleted(this.post.uri)