refactor(admin): only save local draft on autosave failure

- Remove redundant localStorage saves on every form change
- Only save draft when autosave status is 'error' or 'offline'
- Reduces draft recovery banner noise for successful autosaves
- Navigation guard still prevents data loss when navigating away

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-10-07 13:09:39 -07:00
parent dfbf45f8a4
commit f35fa60207

View file

@ -158,13 +158,22 @@
clearDraft(draftKey)
}
// Trigger autosave and store local draft when formData changes (edit mode)
// Trigger autosave when formData changes (edit mode)
$effect(() => {
// Establish dependencies on fields
formData; activeTab
if (mode === 'edit' && hasLoaded && autoSave) {
autoSave.schedule()
if (draftKey) saveDraft(draftKey, buildPayload())
}
})
// Save draft only when autosave fails
$effect(() => {
if (mode === 'edit' && autoSave && draftKey) {
const status = autoSave.status
if (status === 'error' || status === 'offline') {
saveDraft(draftKey, buildPayload())
}
}
})