trying to fix the error in reloading menu
This commit is contained in:
parent
5b44e3147e
commit
5ee8280e3e
1 changed files with 14 additions and 10 deletions
|
|
@ -46,7 +46,7 @@ export class mzta_Menus {
|
||||||
this.allPrompts.forEach((prompt) => {
|
this.allPrompts.forEach((prompt) => {
|
||||||
this.addAction(prompt)
|
this.addAction(prompt)
|
||||||
});
|
});
|
||||||
//this.addMenu(this.rootMenu);
|
//await this.addMenu(this.rootMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reload(){
|
async reload(){
|
||||||
|
|
@ -126,30 +126,34 @@ export class mzta_Menus {
|
||||||
|
|
||||||
async loadMenus() {
|
async loadMenus() {
|
||||||
await this.initialize();
|
await this.initialize();
|
||||||
this.addMenu(this.rootMenu);
|
await this.addMenu(this.rootMenu);
|
||||||
let listeners = this.menu_listeners;
|
let listeners = this.menu_listeners;
|
||||||
browser.menus.onClicked.addListener((info, tab) => {
|
browser.menus.onClicked.addListener((info, tab) => {
|
||||||
listeners[info.menuItemId] && listeners[info.menuItemId] (info, tab);
|
listeners[info.menuItemId] && listeners[info.menuItemId] (info, tab);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addMenu = (menu, root = null) => {
|
addMenu = async (menu, root = null) => {
|
||||||
for (let item of menu) {
|
for (let item of menu) {
|
||||||
let {id, is_default, name, menu, act} = item;
|
let {id, is_default, name, menu, act} = item;
|
||||||
|
|
||||||
browser.menus.create({
|
await new Promise(resolve =>
|
||||||
id: id,
|
browser.menus.create({
|
||||||
title: this.getCustomTextAttribute(id) + is_default == 1 ? (browser.i18n.getMessage(id) || name) : name,
|
id: id,
|
||||||
contexts: this.getContexts(id),
|
title: this.getCustomTextAttribute(id) + is_default == 1 ? (browser.i18n.getMessage(id) || name) : name,
|
||||||
parentId: root
|
contexts: this.getContexts(id),
|
||||||
});
|
parentId: root
|
||||||
|
},
|
||||||
|
resolve
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (act) {
|
if (act) {
|
||||||
this.menu_listeners[id] = act;
|
this.menu_listeners[id] = act;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu) {
|
if (menu) {
|
||||||
this.addMenu(menu, id);
|
await this.addMenu(menu, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue