Skip to content

Commit

Permalink
Update new items menu list when changing status names
Browse files Browse the repository at this point in the history
Fixes #57
  • Loading branch information
Dominic-DallOsto committed Sep 11, 2024
1 parent 349a639 commit 417a525
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/prefs-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ function onPrefsLoad(window: Window) {
fillAutomaticallyLabelNewItemsMenuList(window);
}

function resetPrefsMenu(window: Window) {
clearTableOpenItem(window);
setTableOpenItem(window);
clearAutomaticallyLabelNewItemsMenuList(window);
fillAutomaticallyLabelNewItemsMenuList(window);
}

function setTableStatusNames(window: Window) {
const tableBodyStatusNames = window.document.getElementById(
STATUS_NAMES_TABLE_BODY,
Expand Down Expand Up @@ -85,8 +92,7 @@ function resetTableStatusNames(window: Window) {
);
setTableStatusNames(window);
// if we change the statuses, need to reset the status lists here
clearTableOpenItem(window);
setTableOpenItem(window);
resetPrefsMenu(window);
}

function resetTableOpenItem(window: Window) {
Expand Down Expand Up @@ -218,11 +224,9 @@ function saveTableStatusNames(window: Window) {
);
return;
}

setPref(STATUS_NAME_AND_ICON_LIST_PREF, listToPrefString(names, icons));
// if we change the statuses, need to reset the status lists here
clearTableOpenItem(window);
setTableOpenItem(window);
resetPrefsMenu(window);
}

function saveTableOpenItem(window: Window) {
Expand Down Expand Up @@ -390,6 +394,13 @@ function fillAutomaticallyLabelNewItemsMenuList(window: Window) {
);
}

function clearAutomaticallyLabelNewItemsMenuList(window: Window) {
const listRows = window.document.getElementById(
LABEL_NEW_ITEMS_MENU_LIST,
)?.children;
Array.from(listRows ?? []).map((row) => row.remove());
}

export default {
onPrefsLoad,
addTableRowStatusNames,
Expand Down

0 comments on commit 417a525

Please sign in to comment.