refactor: dont get user relays

This commit is contained in:
verbiricha 2023-07-31 18:27:17 +02:00
parent ec82f9946f
commit ef44a80121
2 changed files with 2 additions and 27 deletions

View File

@ -37,13 +37,7 @@ export function useLoginEvents(pubkey?: string, leaveOpen = false) {
})
.withFilter()
.authors([pubkey])
.kinds([
EventKind.ContactList,
EventKind.Relays,
MUTED,
USER_EMOJIS,
USER_CARDS,
]);
.kinds([EventKind.ContactList, MUTED, USER_EMOJIS, USER_CARDS]);
return b;
}, [pubkey, leaveOpen]);
@ -70,9 +64,6 @@ export function useLoginEvents(pubkey?: string, leaveOpen = false) {
if (ev?.kind === EventKind.ContactList) {
Login.setFollows(ev.tags, ev.content, ev.created_at);
}
if (ev?.kind === EventKind.Relays) {
Login.setRelays(ev.tags, ev.created_at);
}
}
}, [data]);

View File

@ -2,8 +2,7 @@ import { bytesToHex } from "@noble/curves/abstract/utils";
import { schnorr } from "@noble/curves/secp256k1";
import { ExternalStore } from "@snort/shared";
import { EventPublisher, Nip7Signer, PrivateKeySigner } from "@snort/system";
import type { EmojiPack, Relays } from "types";
import { defaultRelays } from "const";
import type { EmojiPack } from "types";
export enum LoginType {
Nip7 = "nip7",
@ -23,7 +22,6 @@ export interface LoginSession {
follows: ReplaceableTags;
muted: ReplaceableTags;
cards: ReplaceableTags;
relays: Relays;
emojis: Array<EmojiPack>;
}
@ -31,7 +29,6 @@ const initialState = {
follows: { tags: [], timestamp: 0 },
muted: { tags: [], timestamp: 0 },
cards: { tags: [], timestamp: 0 },
relays: defaultRelays,
emojis: [],
};
@ -113,19 +110,6 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
this.#save();
}
setRelays(relays: Array<string>, ts: number) {
if (this.#session.relays.timestamp >= ts) {
return;
}
this.#session.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 } };
}, {});
this.#save();
}
#save() {
if (this.#session) {
window.localStorage.setItem(SESSION_KEY, JSON.stringify(this.#session));