From e9cb2fedeb91c44a4f6e217f5aacf8f354e51cdc Mon Sep 17 00:00:00 2001 From: Mic Date: Wed, 15 May 2024 23:18:47 +0200 Subject: [PATCH] ordering prompts in the menu: first the default prompts, then the custom in alphabetical order by "name" --- js/mzta-menus.js | 3 ++- js/mzta-prompts.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/mzta-menus.js b/js/mzta-menus.js index dba7df8b..ef44d5fa 100644 --- a/js/mzta-menus.js +++ b/js/mzta-menus.js @@ -46,7 +46,8 @@ export class mzta_Menus { this.allPrompts = []; this.rootMenu = []; this.menu_listeners = {}; - this.allPrompts = await getPrompts(true); + this.allPrompts = await getPrompts(true); + this.allPrompts.sort((a, b) => a.name.localeCompare(b.name)); this.allPrompts.forEach((prompt) => { this.addAction(prompt) }); diff --git a/js/mzta-prompts.js b/js/mzta-prompts.js index 291b18b8..fba91f97 100644 --- a/js/mzta-prompts.js +++ b/js/mzta-prompts.js @@ -144,8 +144,9 @@ export async function getPrompts(onlyEnabled = false){ let output = defaultPrompts.concat(customPrompts); if(onlyEnabled){ output = output.filter(obj => obj.enabled != 0); - } + }else{ // order only if we are not filtering, the filtering is for the menus and we are ordering there after i18n output.sort((a, b) => a.id.localeCompare(b.id)); + } for(let i=1; i<=output.length; i++){ output[i-1].idnum = i; }