about summary refs log tree commit diff
path: root/src/state/models/muted-threads.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/muted-threads.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/muted-threads.ts')
-rw-r--r--src/state/models/muted-threads.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/state/models/muted-threads.ts b/src/state/models/muted-threads.ts
new file mode 100644
index 000000000..e6f202745
--- /dev/null
+++ b/src/state/models/muted-threads.ts
@@ -0,0 +1,29 @@
+/**
+ * This is a temporary client-side system for storing muted threads
+ * When the system lands on prod we should switch to that
+ */
+
+import {makeAutoObservable} from 'mobx'
+import {isObj, hasProp, isStrArray} from 'lib/type-guards'
+
+export class MutedThreads {
+  uris: Set<string> = new Set()
+
+  constructor() {
+    makeAutoObservable(
+      this,
+      {serialize: false, hydrate: false},
+      {autoBind: true},
+    )
+  }
+
+  serialize() {
+    return {uris: Array.from(this.uris)}
+  }
+
+  hydrate(v: unknown) {
+    if (isObj(v) && hasProp(v, 'uris') && isStrArray(v.uris)) {
+      this.uris = new Set(v.uris)
+    }
+  }
+}