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;
// 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) => {