forked from Kieran/zap.stream
fix: set emojis when session available
This commit is contained in:
parent
ecc54d5d3d
commit
438d72d188
@ -87,6 +87,8 @@ export function useLoginEvents(pubkey?: string, leaveOpen = false) {
|
||||
|
||||
const emojis = useUserEmojiPacks(pubkey, userEmojis);
|
||||
useEffect(() => {
|
||||
Login.setEmojis(emojis);
|
||||
}, [emojis]);
|
||||
if (session) {
|
||||
Login.setEmojis(emojis);
|
||||
}
|
||||
}, [session, emojis]);
|
||||
}
|
||||
|
@ -35,12 +35,14 @@ const initialState = {
|
||||
emojis: [],
|
||||
};
|
||||
|
||||
const SESSION_KEY = "session";
|
||||
|
||||
export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
||||
#session?: LoginSession;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
const json = window.localStorage.getItem("session");
|
||||
const json = window.localStorage.getItem(SESSION_KEY);
|
||||
if (json) {
|
||||
this.#session = { ...initialState, ...JSON.parse(json) };
|
||||
if (this.#session) {
|
||||
@ -126,9 +128,9 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
||||
|
||||
#save() {
|
||||
if (this.#session) {
|
||||
window.localStorage.setItem("session", JSON.stringify(this.#session));
|
||||
window.localStorage.setItem(SESSION_KEY, JSON.stringify(this.#session));
|
||||
} else {
|
||||
window.localStorage.removeItem("session");
|
||||
window.localStorage.removeItem(SESSION_KEY);
|
||||
}
|
||||
this.notifyChange();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user