fix(import): hydrate state on import
This commit is contained in:
parent
5e89d0e64f
commit
ef0c982d98
2 changed files with 3 additions and 5 deletions
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue