diff --git a/src/app/commands.ts b/src/app/commands.ts index 09bb8042..928f92fe 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -140,6 +140,8 @@ export const loginWithNip46 = async ({ if (!pubkey) return false + await loadUserData(pubkey) + const handler = {relays, pubkey: signerPubkey} addSession({method: "nip46", pubkey, secret: clientSecret, handler}) @@ -153,13 +155,16 @@ export const loadUserData = ( pubkey: string, request: Partial = {}, ) => { - const promise = Promise.all([ - loadInboxRelaySelections(pubkey, request), - loadMembership(pubkey, request), - loadSettings(pubkey, request), - loadProfile(pubkey, request), - loadFollows(pubkey, request), - loadMutes(pubkey, request), + const promise = Promise.race([ + sleep(3000), + Promise.all([ + loadInboxRelaySelections(pubkey, request), + loadMembership(pubkey, request), + loadSettings(pubkey, request), + loadProfile(pubkey, request), + loadFollows(pubkey, request), + loadMutes(pubkey, request), + ]), ]) // Load followed profiles slowly in the background without clogging other stuff up diff --git a/src/app/components/LogIn.svelte b/src/app/components/LogIn.svelte index 05fdeb64..a2095ab0 100644 --- a/src/app/components/LogIn.svelte +++ b/src/app/components/LogIn.svelte @@ -20,28 +20,27 @@ const signUp = () => pushModal(SignUp) const withLoading = - (cb: (...args: any[]) => any) => + (s: string, cb: (...args: any[]) => any) => async (...args: any[]) => { - loading = true + loading = s try { await cb(...args) } finally { - loading = false + loading = undefined } } const onSuccess = async (session: Session, relays: string[] = []) => { - addSession(session) - await loadUserData(session.pubkey, {relays}) + addSession(session) pushToast({message: "Successfully logged in!"}) setChecked("*") clearModals() } - const loginWithNip07 = withLoading(async () => { + const loginWithNip07 = withLoading("nip07", async () => { const pubkey = await getNip07()?.getPublicKey() if (pubkey) { @@ -54,7 +53,7 @@ } }) - const loginWithSigner = withLoading(async (app: any) => { + const loginWithNip55 = withLoading("nip55", async (app: any) => { const signer = new Nip55Signer(app.packageName) const pubkey = await signer.getPubkey() @@ -72,8 +71,8 @@ const loginWithBunker = () => pushModal(LogInBunker) - let loading = false let signers: any[] = [] + let loading: string | undefined let hasNativeSigner = Boolean(getNip07()) onMount(async () => { @@ -96,7 +95,7 @@

{#if BURROW_URL}