feat: profile page

This commit is contained in:
Alejandro Gomez
2023-06-30 13:15:31 +02:00
parent 9a08dd6768
commit 111eea3d14
24 changed files with 745 additions and 152 deletions

View File

@ -1,29 +1,31 @@
import { ExternalStore } from "@snort/shared";
export interface LoginSession {
pubkey: string
pubkey: string;
follows: string[];
}
export class LoginStore extends ExternalStore<LoginSession | undefined> {
#session?: LoginSession;
#session?: LoginSession;
constructor() {
super();
const json = window.localStorage.getItem("session");
if (json) {
this.#session = JSON.parse(json);
}
constructor() {
super();
const json = window.localStorage.getItem("session");
if (json) {
this.#session = JSON.parse(json);
}
}
loginWithPubkey(pk: string) {
this.#session = {
pubkey: pk
};
window.localStorage.setItem("session", JSON.stringify(this.#session));
this.notifyChange();
}
loginWithPubkey(pk: string) {
this.#session = {
pubkey: pk,
follows: [],
};
window.localStorage.setItem("session", JSON.stringify(this.#session));
this.notifyChange();
}
takeSnapshot() {
return this.#session ? { ...this.#session } : undefined;
}
}
takeSnapshot() {
return this.#session ? { ...this.#session } : undefined;
}
}