Skip to content

Commit 485b0d0

Browse files
authored
Pins Addon -- Fix Extension Blocks not removing from Pinned on removal
1 parent 1848315 commit 485b0d0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/addons/addons/block-pins/userscript.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export default async function({ addon }) {
266266
// 1 second is a good buffer
267267
populateCategory();
268268
const toolbox = Blockly.mainWorkspace.getToolbox();
269+
if (!toolbox) return;
269270
toolbox.populate_(toolbox.workspace_.options.languageTree);
270271
}, 1000);
271272
}
@@ -280,10 +281,12 @@ export default async function({ addon }) {
280281
if (!autoLoadExtPins) vm.runtime.on("EXTENSION_ADDED", () => {
281282
populateInit = 2;
282283
});
283-
vm.runtime.on("EXTENSION_REMOVED", () => queueMicrotask(() => {
284-
updatePinCategory();
284+
vm.runtime.on("EXTENSION_REMOVED", (extId) => {
285+
// remove blocks in the removed extension from pins
286+
pins = pins.filter((t) => !t.startsWith(extId));
287+
285288
populateInit = 2;
286-
}));
289+
});
287290
addon.self.addEventListener("disabled", () => {
288291
localStorage.removeItem("ADDONS_BLOCK-PINS");
289292
});

0 commit comments

Comments
 (0)