diff options
Diffstat (limited to 'src/state/models/muted-threads.ts')
-rw-r--r-- | src/state/models/muted-threads.ts | 29 |
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) + } + } +} |