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() {
|
||||
if (!charData) return;
|
||||
const char = await roster.create(charData.template);
|
||||
Object.assign(char.data, charData.data);
|
||||
roster.scheduleSave(char);
|
||||
await roster.create(charData.template, charData.data);
|
||||
onClose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ export const roster = {
|
|||
}
|
||||
},
|
||||
|
||||
async create(template: Template) {
|
||||
async create(template: Template, data: Record<string, unknown> = {}) {
|
||||
const char: Character = {
|
||||
id: crypto.randomUUID(),
|
||||
template: $state.snapshot(template),
|
||||
data: {}
|
||||
data: { ...data }
|
||||
};
|
||||
characters.push(char);
|
||||
activeId = char.id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue