Fix a memory leak and loading on amber login

This commit is contained in:
Jon Staab
2024-11-18 16:14:57 -08:00
parent ae69da0be7
commit 165bfb1b2b
2 changed files with 12 additions and 10 deletions
+11 -9
View File
@@ -17,15 +17,17 @@
const signUp = () => pushModal(SignUp) const signUp = () => pushModal(SignUp)
const withLoading = (cb: () => void) => async () => { const withLoading =
loading = true (cb: (...args: any[]) => any) =>
async (...args: any[]) => {
loading = true
try { try {
await cb() await cb(...args)
} finally { } finally {
loading = false loading = false
}
} }
}
const onSuccess = async (session: Session, relays: string[] = []) => { const onSuccess = async (session: Session, relays: string[] = []) => {
addSession(session) addSession(session)
@@ -50,7 +52,7 @@
} }
}) })
const loginWithSigner = async (app: any) => { const loginWithSigner = withLoading(async (app: any) => {
const signer = new Nip55Signer(app.packageName) const signer = new Nip55Signer(app.packageName)
const pubkey = await signer.getPubkey() const pubkey = await signer.getPubkey()
@@ -62,7 +64,7 @@
message: "Something went wrong! Please try again.", message: "Something went wrong! Please try again.",
}) })
} }
} })
const loginWithBunker = () => pushModal(LogInBunker) const loginWithBunker = () => pushModal(LogInBunker)
+1 -1
View File
@@ -209,7 +209,7 @@
}) })
// Listen for new notifications/memberships // Listen for new notifications/memberships
subscribePersistent({ unsubRooms = subscribePersistent({
relays, relays,
filters: [ filters: [
{kinds: [THREAD], since}, {kinds: [THREAD], since},