Replace setTimeout with a listener

This commit is contained in:
GogoVega 2024-03-26 13:05:38 +01:00
parent 9a07fc03c6
commit 4788b81220
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -676,10 +676,12 @@ RED.palette = (function() {
}); });
const collapse = JSON.parse(localStorage.getItem("palette-collapse") || "[]"); const collapse = JSON.parse(localStorage.getItem("palette-collapse") || "[]");
setTimeout(function () { const callback = function () {
collapse.forEach((category) => categoryContainers[category]?.close()); collapse.forEach((category) => categoryContainers[category]?.close());
$("#red-ui-palette-search input").searchBox("value", (localStorage.getItem("palette-filter") || "")); $("#red-ui-palette-search input").searchBox("value", (localStorage.getItem("palette-filter") || ""));
}, 1000); RED.events.off("runtime-state", callback);
};
RED.events.on("runtime-state", callback);
} }
function togglePalette(state) { function togglePalette(state) {
if (!state) { if (!state) {