Browse Source

fix: remember logged in user

fixes
nostr:note18fd52cmq7h6nj32k0xr9q24e0s2j2t0eyqwcamydavut33km7n8qv8mfpg
and
note1pptglp3qmn3nnfc0k7t7mf5y6yv9jq4h72qsf69wtz8e90zs55yqgvr6dq
master
DanConwayDev 2 years ago
parent
commit
7cb3df2dff
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 3
      src/lib/stores/users.ts

3
src/lib/stores/users.ts

@ -80,6 +80,7 @@ export const nip07_plugin: Writable<undefined | boolean> = writable(undefined) @@ -80,6 +80,7 @@ export const nip07_plugin: Writable<undefined | boolean> = writable(undefined)
export const checkForNip07Plugin = () => {
if (window.nostr) {
nip07_plugin.set(true)
if (localStorage.getItem('nip07pubkey')) login()
} else {
let timerId: NodeJS.Timeout | undefined = undefined
const intervalId = setInterval(() => {
@ -87,6 +88,7 @@ export const checkForNip07Plugin = () => { @@ -87,6 +88,7 @@ export const checkForNip07Plugin = () => {
clearTimeout(timerId)
clearInterval(intervalId)
nip07_plugin.set(true)
if (localStorage.getItem('nip07pubkey')) login()
}
}, 100)
timerId = setTimeout(() => {
@ -108,6 +110,7 @@ export const login = async (): Promise<void> => { @@ -108,6 +110,7 @@ export const login = async (): Promise<void> => {
if (get(nip07_plugin)) {
try {
const ndk_user = await signer.blockUntilReady()
localStorage.setItem('nip07pubkey', ndk_user.pubkey)
logged_in_user.set({
...user_defaults,
hexpubkey: ndk_user.pubkey,

Loading…
Cancel
Save