Merge pull request #66 from zero01101/bleeding-edge

fix resource manager persistence
This commit is contained in:
Victor Seiji Hariki 2022-12-03 23:03:01 -03:00 committed by GitHub
commit a57c8896f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) => {