|
15 | 15 | import { AuthLastUsedFlow } from "$lib/flows/authLastUsedFlow.svelte"; |
16 | 16 | import Header from "$lib/components/layout/Header.svelte"; |
17 | 17 | import Footer from "$lib/components/layout/Footer.svelte"; |
18 | | - import { goto } from "$app/navigation"; |
| 18 | + import { goto, preloadData } from "$app/navigation"; |
19 | 19 | import ProgressRing from "$lib/components/ui/ProgressRing.svelte"; |
20 | 20 | import { AuthWizard } from "$lib/components/wizards/auth"; |
21 | 21 | import type { PageProps } from "./$types"; |
|
30 | 30 |
|
31 | 31 | const { data }: PageProps = $props(); |
32 | 32 |
|
33 | | - const gotoNext = () => goto(data.next ?? "/manage", { replaceState: true }); |
| 33 | + let redirectingIdentity = $state<bigint>(); |
34 | 34 |
|
| 35 | + // Show loading indicator until load function of next page has been preloaded |
| 36 | + const gotoNext = async (identityNumber: bigint) => { |
| 37 | + redirectingIdentity = identityNumber; |
| 38 | + const next = data.next ?? "/manage"; |
| 39 | + await preloadData(next); |
| 40 | + await goto(next, { replaceState: true }); |
| 41 | + }; |
35 | 42 | const onMigration = async (identityNumber: bigint) => { |
36 | 43 | lastUsedIdentitiesStore.selectIdentity(identityNumber); |
37 | 44 | toaster.success({ |
38 | 45 | title: $t`Migration completed successfully`, |
39 | 46 | duration: 4000, |
40 | 47 | }); |
41 | 48 | isAuthDialogOpen = false; |
42 | | - await goto("/manage"); |
| 49 | + await gotoNext(identityNumber); |
43 | 50 | }; |
44 | 51 | const onSignIn = async (identityNumber: bigint) => { |
45 | 52 | lastUsedIdentitiesStore.selectIdentity(identityNumber); |
46 | 53 | isAuthDialogOpen = false; |
47 | 54 | authenticationV2Funnel.trigger(AuthenticationV2Events.GoToDashboard); |
48 | 55 | authenticationV2Funnel.close(); |
49 | | - await gotoNext(); |
| 56 | + await gotoNext(identityNumber); |
50 | 57 | }; |
51 | 58 | const onSignUp = async (identityNumber: bigint) => { |
52 | 59 | toaster.success({ |
|
57 | 64 | isAuthDialogOpen = false; |
58 | 65 | authenticationV2Funnel.trigger(AuthenticationV2Events.GoToDashboard); |
59 | 66 | authenticationV2Funnel.close(); |
60 | | - await gotoNext(); |
| 67 | + await gotoNext(identityNumber); |
61 | 68 | }; |
62 | 69 |
|
63 | 70 | const lastUsedIdentities = $derived( |
|
111 | 118 | <li class="contents"> |
112 | 119 | <ButtonCard |
113 | 120 | onclick={() => handleContinueAs(identity)} |
114 | | - disabled={nonNullish(authLastUsedFlow.authenticatingIdentity)} |
| 121 | + disabled={nonNullish( |
| 122 | + authLastUsedFlow.authenticatingIdentity, |
| 123 | + ) || nonNullish(redirectingIdentity)} |
115 | 124 | > |
116 | 125 | <Avatar size="sm"> |
117 | | - {#if identity.identityNumber === authLastUsedFlow.authenticatingIdentity} |
| 126 | + {#if identity.identityNumber === authLastUsedFlow.authenticatingIdentity || identity.identityNumber === redirectingIdentity} |
118 | 127 | <ProgressRing /> |
119 | 128 | {:else} |
120 | 129 | <UserIcon class="size-5" /> |
|
134 | 143 | </ul> |
135 | 144 | <ButtonCard |
136 | 145 | onclick={() => (isAuthDialogOpen = true)} |
137 | | - disabled={nonNullish(authLastUsedFlow.authenticatingIdentity)} |
| 146 | + disabled={nonNullish(authLastUsedFlow.authenticatingIdentity) || |
| 147 | + nonNullish(redirectingIdentity)} |
138 | 148 | > |
139 | 149 | <FeaturedIcon size="sm"> |
140 | 150 | <PlusIcon class="size-5" /> |
|
0 commit comments