feat: mute list
This commit is contained in:
49
src/login.ts
49
src/login.ts
@ -72,6 +72,11 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
|||||||
this.#save();
|
this.#save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSession(s: LoginSession) {
|
||||||
|
this.#session = s;
|
||||||
|
this.#save();
|
||||||
|
}
|
||||||
|
|
||||||
takeSnapshot() {
|
takeSnapshot() {
|
||||||
return this.#session ? { ...this.#session } : undefined;
|
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 } };
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user