Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): ensure goto is awaited for login page #12087

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/src/routes/auth/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
</p>

<LoginForm
onSuccess={() => goto(AppRoute.PHOTOS, { invalidateAll: true })}
onFirstLogin={() => goto(AppRoute.AUTH_CHANGE_PASSWORD)}
onOnboarding={() => goto(AppRoute.AUTH_ONBOARDING)}
onSuccess={async () => await goto(AppRoute.PHOTOS, { invalidateAll: true })}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The before and after look equivalent to me and actually the before might be slightly more performant and less code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that without awaiting the function, it would hang at the login page instead of navigating to the route 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a race condition and you're just getting lucky/unlucky?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that without awaiting the function, it would hang at the login page instead of navigating to the route 🤔

FYI () => <some promise> does not mean it's not awaited. That's just syntactic sugar for async () => {await <some promise>} (and other things). So it should really not make a difference. In fact, I think we should always use () => where possible and afaik @jrasm91 advocates for this as well, so not really sure why you approved it - probably just overlooked it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm so there seems to be a different issue here

onFirstLogin={async () => await goto(AppRoute.AUTH_CHANGE_PASSWORD)}
onOnboarding={async () => await goto(AppRoute.AUTH_ONBOARDING)}
/>
</FullscreenContainer>
{/if}
2 changes: 2 additions & 0 deletions web/src/routes/auth/onboarding/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import OnboadingStorageTemplate from '$lib/components/onboarding-page/onboarding-storage-template.svelte';
import OnboardingTheme from '$lib/components/onboarding-page/onboarding-theme.svelte';
import { AppRoute, QueryParameter } from '$lib/constants';
import { retrieveServerConfig } from '$lib/stores/server-config.store';
import { updateAdminOnboarding } from '@immich/sdk';

let index = 0;
Expand Down Expand Up @@ -35,6 +36,7 @@
const handleDoneClicked = async () => {
if (index >= onboardingSteps.length - 1) {
await updateAdminOnboarding({ adminOnboardingUpdateDto: { isOnboarded: true } });
await retrieveServerConfig();
await goto(AppRoute.PHOTOS);
} else {
index++;
Expand Down
Loading