diff --git a/src/routes/accounts/+page.svelte b/src/routes/accounts/+page.svelte index 9c4e8d05..f1dd05db 100644 --- a/src/routes/accounts/+page.svelte +++ b/src/routes/accounts/+page.svelte @@ -20,6 +20,37 @@ let newInstance: string = $instance let loading = false + + async function changeGuestInstance() { + loading = true + try { + const valid = await validateInstance(newInstance.trim()) + + if (!valid) { + throw new Error('invalid instance') + } + + toast({ + content: 'Changed guest instance.', + type: ToastType.success, + }) + } catch (err) { + toast({ + content: 'Failed to contact that instance URL. Is it down?', + type: ToastType.error, + }) + + loading = false + + return + } + + $profileData.defaultInstance = newInstance + if ($currentProfile && $currentProfile.id == -1) { + $instance = newInstance + } + loading = false + } @@ -42,36 +73,7 @@
{ - loading = true - try { - const valid = await validateInstance(newInstance.trim()) - - if (!valid) { - throw new Error('invalid instance') - } - - toast({ - content: 'Changed guest instance.', - type: ToastType.success, - }) - } catch (err) { - toast({ - content: 'Failed to contact that instance URL. Is it down?', - type: ToastType.error, - }) - - loading = false - - return - } - - $profileData.defaultInstance = newInstance - if ($currentProfile && $currentProfile.id == -1) { - $instance = newInstance - } - loading = false - }} + on:change={changeGuestInstance} placeholder="Instance URL" bind:value={newInstance} disabled={LINKED_INSTANCE_URL != undefined} @@ -141,49 +143,7 @@
{/each}
- - Guest -
- { - loading = true - try { - const valid = await validateInstance(newInstance.trim()) - - if (!valid) { - throw new Error('invalid instance') - } - - toast({ - content: 'Changed guest instance.', - type: ToastType.success, - }) - } catch (err) { - toast({ - content: 'Failed to contact that instance URL. Is it down?', - type: ToastType.error, - }) - } - - $profileData.defaultInstance = newInstance - if ($currentProfile && $currentProfile.id == -1) { - $instance = newInstance - } - loading = false - }} - placeholder="Instance URL" - bind:value={newInstance} - disabled={LINKED_INSTANCE_URL != undefined} - /> - -
-
+ Guest
- +
+