Skip to content
Open
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
19 changes: 11 additions & 8 deletions frontend/src/lib/components/settings/AccountForm.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { untrack } from 'svelte'
import Icon from '@iconify/svelte'
import { Button } from '$lib/components/ui/button'
import { Input } from '$lib/components/ui/input'
Expand Down Expand Up @@ -126,6 +127,7 @@
let color = $state('')
let email = $state('')
let prevEmail = $state('')
let prevAutoName = ''
let username = $state('')
let password = $state('')
let imapHost = $state('')
Expand Down Expand Up @@ -482,8 +484,10 @@
$effect(() => {
if (!email) return

// Auto-fill username with full email
if (!username || username === prevEmail) {
// Auto-fill username with full email. Read the fields untracked so that
// clearing one does not re-run this effect and fill it straight back in.
const previous = untrack(() => prevEmail)
if (untrack(() => !username || username === previous)) {
username = email
}
prevEmail = email
Expand All @@ -494,12 +498,11 @@
selectProvider(detected)
}

// Auto-fill name from email if empty
if (!name) {
const localPart = email.split('@')[0]
if (localPart) {
name = localPart.charAt(0).toUpperCase() + localPart.slice(1)
}
// Auto-fill name from email, unless the user has typed their own
const localPart = email.split('@')[0]
if (localPart && untrack(() => !name || name === prevAutoName)) {
name = localPart.charAt(0).toUpperCase() + localPart.slice(1)
prevAutoName = name
}
})

Expand Down