Skip to content

Commit

Permalink
Stabilise email-result handling
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Oct 27, 2023
1 parent 7a7d781 commit c80a629
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions frontend/src/routes/(authenticated)/user/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { emailResult, requestedEmail } from '$lib/email/EmailVerificationStatus.svelte';
import { requestedEmail } from '$lib/email/EmailVerificationStatus.svelte';
import { SubmitButton, Form, FormError, Input, lexSuperForm } from '$lib/forms';
import t from '$lib/i18n';
import { Page } from '$lib/layout';
Expand All @@ -19,8 +19,6 @@
$: user = data?.user;
let deleteModal: DeleteUserModal;
$: if (data.emailResult) emailResult.set(data.emailResult);
async function openDeleteModal(): Promise<void> {
let { response } = await deleteModal.open(user);
if (response == DialogResponse.Submit) {
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/routes/(authenticated)/user/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { emailResult as emailResultStore } from '$lib/email/EmailVerificationStatus.svelte';
import type {
$OpResult,
ChangeUserAccountDataMutation,
ChangeUserAccountDataInput,

} from '$lib/gql/types';
import { getClient, graphql } from '$lib/gql';
import { goto } from '$app/navigation';
Expand All @@ -16,9 +16,13 @@ export const load = (({ url }) => {
const emailResult = url.searchParams.get('emailResult') as EmailResult | null;
if (emailResult) {
if (!EMAIL_RESULTS.includes(emailResult)) throw new Error(`Invalid emailResult: ${emailResult}.`);
if (browser) void goto(`${url.pathname}`, { replaceState: true });
if (browser) {
void goto(`${url.pathname}`, { replaceState: true });
// ES Lint probably doesn't like this, because it's from a Svelte file
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
emailResultStore.set(emailResult);
}
}
return { emailResult };
}) satisfies PageLoad

export async function _changeUserAccountData(input: ChangeUserAccountDataInput): $OpResult<ChangeUserAccountDataMutation> {
Expand Down

0 comments on commit c80a629

Please sign in to comment.