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;
|
||||
|
||||
// Performs resource fetch from local storage
|
||||
{
|
||||
(async () => {
|
||||
const storageResources = localStorage.getItem(
|
||||
"tools.stamp.resources"
|
||||
);
|
||||
if (storageResources) {
|
||||
const parsed = JSON.parse(storageResources);
|
||||
state.resources.push(
|
||||
...parsed.map((resource) => {
|
||||
const image = document.createElement("img");
|
||||
image.src = resource.src;
|
||||
...(await Promise.all(
|
||||
parsed.map((resource) => {
|
||||
const image = document.createElement("img");
|
||||
image.src = resource.src;
|
||||
|
||||
return {
|
||||
id: resource.id,
|
||||
name: resource.name,
|
||||
image,
|
||||
};
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
image.onload = () =>
|
||||
resolve({id: resource.id, name: resource.name, image});
|
||||
});
|
||||
})
|
||||
))
|
||||
);
|
||||
syncResources();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
},
|
||||
populateContextMenu: (menu, state) => {
|
||||
|
|
Loading…
Reference in a new issue