inactive features items hidded. see #680

This commit is contained in:
Mic 2026-04-15 23:31:00 +02:00
parent 14868d4fd4
commit e89ab5beca
2 changed files with 30 additions and 2 deletions

View file

@ -186,6 +186,24 @@ async function _reload_menus() {
return true;
}
async function _getActiveSpecialIds() {
let prefs_reload = await browser.storage.sync.get({add_tags: prefs_default.add_tags, get_calendar_event: prefs_default.get_calendar_event, get_calendar_event_from_clipboard: prefs_default.get_calendar_event_from_clipboard, get_task: prefs_default.get_task, connection_type: prefs_default.connection_type, spamfilter: prefs_default.spamfilter, summarize: prefs_default.summarize, translate: prefs_default.translate});
let getCalendarEvent = doGetSparkFeature(prefs_reload.get_calendar_event);
let getCalendarEventFromClipboard = doGetSparkFeature(prefs_reload.get_calendar_event_from_clipboard);
let getTask = doGetSparkFeature(prefs_reload.get_task);
return getActiveSpecialPromptsIDs({
addtags: prefs_reload.add_tags,
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
get_calendar_event: getCalendarEvent,
get_calendar_event_from_clipboard: getCalendarEventFromClipboard,
get_task: getTask,
spamfilter: prefs_reload.spamfilter,
summarize: prefs_reload.summarize,
translate: prefs_reload.translate,
is_chatgpt_web: (prefs_reload.connection_type === "chatgpt_web")
});
}
async function _assign_tags(_data, create_new_tags = true, exclusions_exact_match = false) {
let all_tags_list = await getTagsList();
all_tags_list = all_tags_list[1];
@ -506,6 +524,9 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
case 'reload_menus':
return _reload_menus();
break;
case 'get_active_special_ids':
return _getActiveSpecialIds();
break;
case 'shortcut_do_prompt':
taLog.log("Executing shortcut, promptId: " + message.promptId);
return menus.executeMenuAction(message.promptId);

View file

@ -20,6 +20,7 @@ import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, setSpecialPr
import { i18nConditionalGet } from '../../js/mzta-utils.js';
let allPrompts = [];
let allExcludedSpecialPrompts = []; // special prompts excluded from UI (hidden + inactive features), preserved on save
let currentPopupView = 'display'; // 'display' or 'compose'
let hasUnsavedChanges = false;
@ -27,8 +28,14 @@ document.addEventListener('DOMContentLoaded', async () => {
allPrompts = await getPrompts(false, [], true);
// Exclude special prompts that are defined with show_in: "none" (internal prompts, not user-toggleable)
// and special prompts whose feature is not active (e.g. add_tags disabled, sparks not present)
const hiddenSpecialIds = getHiddenSpecialPromptIds();
allPrompts = allPrompts.filter(p => !hiddenSpecialIds.includes(p.id));
const activeSpecialIds = await browser.runtime.sendMessage({ command: "get_active_special_ids" });
allExcludedSpecialPrompts = allPrompts.filter(p =>
hiddenSpecialIds.includes(p.id) ||
(String(p.is_special) === '1' && !activeSpecialIds.includes(p.id))
);
allPrompts = allPrompts.filter(p => !allExcludedSpecialPrompts.some(e => e.id === p.id));
// Resolve i18n names and assign initial position_context if missing
let contextPos = 1;
@ -297,7 +304,7 @@ async function saveAll() {
const defaultPromptsToSave = allPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1');
const customPromptsToSave = allPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1');
const specialPromptsToSave = allPrompts.filter(p => String(p.is_special) === '1');
const specialPromptsToSave = allPrompts.filter(p => String(p.is_special) === '1').concat(allExcludedSpecialPrompts);
await setDefaultPromptsProperties(defaultPromptsToSave);
await setCustomPrompts(customPromptsToSave);