about summary refs log tree commit diff
path: root/src/state/models/content/post.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/models/content/post.ts')
-rw-r--r--src/state/models/content/post.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/state/models/content/post.ts b/src/state/models/content/post.ts
index b5d95bf01..7ba633366 100644
--- a/src/state/models/content/post.ts
+++ b/src/state/models/content/post.ts
@@ -48,6 +48,17 @@ export class PostModel implements RemoveIndex<Post.Record> {
     return this.hasLoaded && !this.hasContent
   }
 
+  get rootUri(): string {
+    if (this.reply?.root.uri) {
+      return this.reply.root.uri
+    }
+    return this.uri
+  }
+
+  get isThreadMuted() {
+    return this.rootStore.mutedThreads.uris.has(this.rootUri)
+  }
+
   // public api
   // =
 
@@ -55,6 +66,14 @@ export class PostModel implements RemoveIndex<Post.Record> {
     await this._load()
   }
 
+  async toggleThreadMute() {
+    if (this.isThreadMuted) {
+      this.rootStore.mutedThreads.uris.delete(this.rootUri)
+    } else {
+      this.rootStore.mutedThreads.uris.add(this.rootUri)
+    }
+  }
+
   // state transitions
   // =