atagen

malice

public
Star0
Watch0
d1818305ffd6912e4b9ac7b706c43eccd01bdd21
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git
web/src/lib/muted-spaces.tsTypescript23 lines645 B
1
import { writable } from 'svelte/store';
2
import { getAccountData } from './api';
3
import { NO_MUTED_SPACES, parseMutedSpaces, type MutedSpaces } from './mute-model';
4
5
export const MUTED_SPACES_EVENT = 'dev.malice.muted_spaces';
6
7
export const mutedSpaces = writable<MutedSpaces>(NO_MUTED_SPACES);
8
9
let loaded = false;
10
11
export const mutedSpacesLoaded = () => loaded;
12
13
export async function loadMutedSpaces(): Promise<void> {
14
  try {
15
    mutedSpaces.set(parseMutedSpaces(await getAccountData(MUTED_SPACES_EVENT)));
16
    loaded = true;
17
  } catch {}
18
}
19
20
export function resetMutedSpaces(): void {
21
  loaded = false;
22
  mutedSpaces.set(NO_MUTED_SPACES);
23
}