Merge pull request #66 from zero01101/bleeding-edge
fix resource manager persistence
This commit is contained in:
commit
a57c8896f1
1 changed files with 12 additions and 11 deletions
|
@ -414,27 +414,28 @@ const stampTool = () =>
|
||||||
state.ctxmenu.resourceList = resourceList;
|
state.ctxmenu.resourceList = resourceList;
|
||||||
|
|
||||||
// Performs resource fetch from local storage
|
// Performs resource fetch from local storage
|
||||||
{
|
(async () => {
|
||||||
const storageResources = localStorage.getItem(
|
const storageResources = localStorage.getItem(
|
||||||
"tools.stamp.resources"
|
"tools.stamp.resources"
|
||||||
);
|
);
|
||||||
if (storageResources) {
|
if (storageResources) {
|
||||||
const parsed = JSON.parse(storageResources);
|
const parsed = JSON.parse(storageResources);
|
||||||
state.resources.push(
|
state.resources.push(
|
||||||
...parsed.map((resource) => {
|
...(await Promise.all(
|
||||||
|
parsed.map((resource) => {
|
||||||
const image = document.createElement("img");
|
const image = document.createElement("img");
|
||||||
image.src = resource.src;
|
image.src = resource.src;
|
||||||
|
|
||||||
return {
|
return new Promise((resolve, reject) => {
|
||||||
id: resource.id,
|
image.onload = () =>
|
||||||
name: resource.name,
|
resolve({id: resource.id, name: resource.name, image});
|
||||||
image,
|
});
|
||||||
};
|
|
||||||
})
|
})
|
||||||
|
))
|
||||||
);
|
);
|
||||||
syncResources();
|
syncResources();
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
populateContextMenu: (menu, state) => {
|
populateContextMenu: (menu, state) => {
|
||||||
|
|
Loading…
Reference in a new issue