fix(import): hydrate state on import

This commit is contained in:
Lewis Wynne 2026-03-23 19:41:28 +00:00
parent 5e89d0e64f
commit ef0c982d98
2 changed files with 3 additions and 5 deletions

View file

@ -54,9 +54,7 @@
async function importCharacter() { async function importCharacter() {
if (!charData) return; if (!charData) return;
const char = await roster.create(charData.template); await roster.create(charData.template, charData.data);
Object.assign(char.data, charData.data);
roster.scheduleSave(char);
onClose(); onClose();
} }

View file

@ -33,11 +33,11 @@ export const roster = {
} }
}, },
async create(template: Template) { async create(template: Template, data: Record<string, unknown> = {}) {
const char: Character = { const char: Character = {
id: crypto.randomUUID(), id: crypto.randomUUID(),
template: $state.snapshot(template), template: $state.snapshot(template),
data: {} data: { ...data }
}; };
characters.push(char); characters.push(char);
activeId = char.id; activeId = char.id;