misc: make guest account look better

This commit is contained in:
Xyphyn committed 2023-08-01 15:05:20 -07:00
1 parent 23f0d7aeb4
commit 5dd187e32d
1 file changed
+52 -74
+52 -74
View File
@@ -20,6 +20,37 @@
let newInstance: string = $instance let newInstance: string = $instance
let loading = false 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
}
</script> </script>
<svelte:head> <svelte:head>
@@ -42,36 +73,7 @@
<div class="flex flex-row font-normal gap-2"> <div class="flex flex-row font-normal gap-2">
<TextInput <TextInput
label="Guest instance" label="Guest instance"
on:change={async () => { on:change={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
}}
placeholder="Instance URL" placeholder="Instance URL"
bind:value={newInstance} bind:value={newInstance}
disabled={LINKED_INSTANCE_URL != undefined} disabled={LINKED_INSTANCE_URL != undefined}
@@ -141,49 +143,7 @@
</div> </div>
{/each} {/each}
<div class="flex flex-row gap-4 items-center py-4"> <div class="flex flex-row gap-4 items-center py-4">
<span class="font-bold flex flex-col"> <span class="font-bold flex flex-col">Guest</span>
Guest
<div class="flex flex-row font-normal gap-2">
<TextInput
on:change={async () => {
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}
/>
<Button
color="primary"
{loading}
disabled={loading || LINKED_INSTANCE_URL != undefined}
>
Change
</Button>
</div>
</span>
<div class="ml-auto" /> <div class="ml-auto" />
<Button <Button
@@ -196,7 +156,25 @@
</Button> </Button>
</div> </div>
</EditableList> </EditableList>
<Button href="/login" size="lg" class="mt-auto"> <div class="mt-auto" />
<div class="flex flex-row font-normal gap-2">
<TextInput
on:change={changeGuestInstance}
placeholder="Instance URL"
label="Guest instance"
bind:value={newInstance}
disabled={LINKED_INSTANCE_URL != undefined}
/>
<Button
color="primary"
{loading}
disabled={loading || LINKED_INSTANCE_URL != undefined}
class="h-[42px] self-end"
>
Change
</Button>
</div>
<Button href="/login" size="lg">
<Icon slot="icon" src={Plus} size="16" mini /> <Icon slot="icon" src={Plus} size="16" mini />
Add more Add more
</Button> </Button>