correctly handling the menus loading special prompts. see #183
This commit is contained in:
parent
501fdf2fc1
commit
938c818b99
2 changed files with 13 additions and 9 deletions
|
|
@ -51,24 +51,24 @@ export class mzta_Menus {
|
|||
}
|
||||
|
||||
|
||||
async initialize() {
|
||||
async initialize(also_special = false) {
|
||||
this.allPrompts = [];
|
||||
this.rootMenu = [];
|
||||
this.shortcutMenu = [];
|
||||
this.menu_listeners = {};
|
||||
this.allPrompts = await getPrompts(true,true);
|
||||
this.allPrompts = await getPrompts(true,also_special);
|
||||
this.allPrompts.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.allPrompts.forEach((prompt) => {
|
||||
this.addAction(prompt)
|
||||
});
|
||||
}
|
||||
|
||||
async reload(){
|
||||
async reload(also_special = false) {
|
||||
await browser.menus.removeAll().catch(error => {
|
||||
console.error("[ThunderAI] ERROR removing the menus: ", error);
|
||||
});
|
||||
this.removeClickListener();
|
||||
this.loadMenus();
|
||||
this.loadMenus(also_special);
|
||||
}
|
||||
|
||||
addAction = (curr_prompt) => {
|
||||
|
|
@ -228,8 +228,8 @@ export class mzta_Menus {
|
|||
this.shortcutMenu.push(curr_menu_entry);
|
||||
}
|
||||
|
||||
async loadMenus() {
|
||||
await this.initialize();
|
||||
async loadMenus(also_special = false) {
|
||||
await this.initialize(also_special);
|
||||
await this.addMenu(this.rootMenu);
|
||||
this.addClickListener();
|
||||
this.loadShortcutMenu();
|
||||
|
|
|
|||
|
|
@ -210,9 +210,13 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
return _reloadBody(message.tabId);
|
||||
break;
|
||||
case 'reload_menus':
|
||||
menus.reload();
|
||||
taLog.log("Reloading menus");
|
||||
return Promise.resolve(true);
|
||||
async function _reload_menus() {
|
||||
let prefs = await browser.storage.sync.get({add_tags: false, connection_type: 'chatgpt_web'});
|
||||
menus.reload(prefs.add_tags && (prefs.connection_type !== "chatgpt_web"));
|
||||
taLog.log("Reloading menus");
|
||||
return true;
|
||||
}
|
||||
return _reload_menus();
|
||||
break;
|
||||
case 'shortcut_do_prompt':
|
||||
taLog.log("Executing shortcut, promptId: " + message.promptId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue