menu order reloading fixed. see #680
This commit is contained in:
parent
dd1aba576d
commit
3a506f710f
1 changed files with 5 additions and 5 deletions
|
|
@ -23,7 +23,6 @@ let allPrompts = [];
|
||||||
let allExcludedSpecialPrompts = []; // special prompts excluded from UI (hidden + inactive features), preserved on save
|
let allExcludedSpecialPrompts = []; // special prompts excluded from UI (hidden + inactive features), preserved on save
|
||||||
let allDisabledPrompts = []; // default/custom prompts disabled (enabled=0), excluded from UI, preserved on save
|
let allDisabledPrompts = []; // default/custom prompts disabled (enabled=0), excluded from UI, preserved on save
|
||||||
let currentPopupView = 'display'; // 'display' or 'compose'
|
let currentPopupView = 'display'; // 'display' or 'compose'
|
||||||
let hasUnsavedChanges = false;
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
await loadAndRender();
|
await loadAndRender();
|
||||||
|
|
@ -32,14 +31,17 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
document.getElementById('btnSaveAll').addEventListener('click', saveAll);
|
document.getElementById('btnSaveAll').addEventListener('click', saveAll);
|
||||||
|
|
||||||
// If prompts are modified elsewhere (e.g. custom prompts page saving), reload this page's data.
|
// If prompts are modified elsewhere (e.g. custom prompts page saving), reload this page's data.
|
||||||
// We skip reload if we have unsaved changes, to avoid losing user work.
|
// Any unsaved changes on this page are discarded to avoid overwriting the other page's changes.
|
||||||
let reloadDebounce = null;
|
let reloadDebounce = null;
|
||||||
browser.storage.onChanged.addListener((changes, areaName) => {
|
browser.storage.onChanged.addListener((changes, areaName) => {
|
||||||
if (areaName !== 'local') return;
|
if (areaName !== 'local') return;
|
||||||
if (!(changes._default_prompts_properties || changes._custom_prompt || changes._special_prompts)) return;
|
if (!(changes._default_prompts_properties || changes._custom_prompt || changes._special_prompts)) return;
|
||||||
if (hasUnsavedChanges) return;
|
|
||||||
clearTimeout(reloadDebounce);
|
clearTimeout(reloadDebounce);
|
||||||
reloadDebounce = setTimeout(() => {
|
reloadDebounce = setTimeout(() => {
|
||||||
|
document.getElementById('btnSaveAll').disabled = true;
|
||||||
|
const msgDisplay = document.getElementById('msgDisplay');
|
||||||
|
msgDisplay.textContent = '';
|
||||||
|
msgDisplay.style.display = 'none';
|
||||||
loadAndRender();
|
loadAndRender();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
@ -341,7 +343,6 @@ async function saveAll() {
|
||||||
|
|
||||||
await browser.runtime.sendMessage({ command: "reload_menus" });
|
await browser.runtime.sendMessage({ command: "reload_menus" });
|
||||||
|
|
||||||
hasUnsavedChanges = false;
|
|
||||||
msgDisplay.textContent = browser.i18n.getMessage('menu_order_saved');
|
msgDisplay.textContent = browser.i18n.getMessage('menu_order_saved');
|
||||||
msgDisplay.style.display = 'inline';
|
msgDisplay.style.display = 'inline';
|
||||||
msgDisplay.style.color = 'green';
|
msgDisplay.style.color = 'green';
|
||||||
|
|
@ -352,7 +353,6 @@ async function saveAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function markUnsaved() {
|
function markUnsaved() {
|
||||||
hasUnsavedChanges = true;
|
|
||||||
document.getElementById('btnSaveAll').disabled = false;
|
document.getElementById('btnSaveAll').disabled = false;
|
||||||
const msgDisplay = document.getElementById('msgDisplay');
|
const msgDisplay = document.getElementById('msgDisplay');
|
||||||
msgDisplay.textContent = browser.i18n.getMessage('customPrompts_unsaved_changes');
|
msgDisplay.textContent = browser.i18n.getMessage('customPrompts_unsaved_changes');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue