do not remove what has already been removed

This commit is contained in:
buzz-lightsnack-2007 2024-04-24 14:47:50 +08:00
parent 786302927d
commit 5c86f87394

View file

@ -34,11 +34,12 @@ export default class Menu {
};
remove() {
(!this.hidden) ? chrome.contextMenus.remove(this.ID) : false;
this.hidden = true;
chrome.contextMenus.remove(this.ID);
};
show() {
if (this.hidden || this.hidden == null) {
this.hidden = false;
this.ID = chrome.contextMenus.create(this.#options);
@ -52,6 +53,7 @@ export default class Menu {
});
};
}
}
/* Update the context menu.
@ -71,7 +73,7 @@ export default class Menu {
};
(this.icon) ? this.#options.icon = this.icon : null;
chrome.contextMenus.update(this.ID, this.#options);
(!this.hidden) ? chrome.contextMenus.update(this.ID, this.#options) : false;
(((this.events && (typeof this.events).includes(`obj`) && !Array.isArray(this.events))) ? Object.keys(events) > 0 : false)
? (Object.keys(this.events)).forEach((EVENT) => {