From 5dd187e32dde9fd1710dcaa03113fb0fd1dadaa6 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Tue, 1 Aug 2023 15:05:20 -0700 Subject: [PATCH] misc: make guest account look better --- src/routes/accounts/+page.svelte | 126 +++++++++++++------------------ 1 file changed, 52 insertions(+), 74 deletions(-) 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
- +
+