feat: mute list

This commit is contained in:
verbiricha 2023-07-30 00:26:16 +02:00
parent ef44a80121
commit e726a67413

View File

@ -72,6 +72,11 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
this.#save();
}
updateSession(s: LoginSession) {
this.#session = s;
this.#save();
}
takeSnapshot() {
return this.#session ? { ...this.#session } : undefined;
}
@ -133,3 +138,47 @@ export function getPublisher(session: LoginSession) {
}
}
}
export function setFollows(
state: LoginSession,
follows: Array<string>,
ts: number,
) {
if (state.follows.timestamp >= ts) {
return;
}
state.follows.tags = follows;
state.follows.timestamp = ts;
}
export function setEmojis(state: LoginSession, emojis: Array<EmojiPack>) {
state.emojis = emojis;
}
export function setMuted(
state: LoginSession,
muted: Array<string[]>,
ts: number,
) {
if (state.muted.timestamp >= ts) {
return;
}
state.muted.tags = muted;
state.muted.timestamp = ts;
}
export function setRelays(
state: LoginSession,
relays: Array<string>,
ts: number,
) {
if (state.relays.timestamp >= ts) {
return;
}
state.relays = relays.reduce((acc, r) => {
const [, relay] = r;
const write = r.length === 2 || r.includes("write");
const read = r.length === 2 || r.includes("read");
return { ...acc, [relay]: { read, write } };
}, {});
}