feat(settings): more specific notification handling, and put menu in query to allow user to go back in history to go back in menus

This commit is contained in:
2025-11-26 22:58:03 +01:00
parent d37a793488
commit aa60eb4909
9 changed files with 181 additions and 128 deletions

View File

@@ -1,37 +1,28 @@
export const useSettingsStore = defineStore("settings", {
state: () => ({
activeMenu: null as string | null,
navigationStack: [] as string[],
currentMenu: null as string | null,
currentSubMenu: null as string | null,
}),
getters: {
isMenuOpen: (state) => (menu: string) => {
if (!state.activeMenu) return false;
return new RegExp(`^${menu}[A-Z]`).test(state.activeMenu);
if (!state.currentMenu) return false;
return new RegExp(`^${menu}[A-Z]`).test(state.currentMenu);
},
isAnyOtherMenuOpen: (state) => (excludeMenu: string) => {
if (!state.activeMenu) return false;
if (!state.currentMenu) return false;
return ["options", "clock", "user", "touchScreen"]
.filter((m) => m !== excludeMenu)
.some((m) => new RegExp(`^${m}[A-Z]`).test(state.activeMenu!));
},
currentView: (state) => {
if (state.navigationStack.length === 0) return "menu";
return state.navigationStack[state.navigationStack.length - 1];
.some((m) => new RegExp(`^${m}[A-Z]`).test(state.currentMenu!));
},
},
actions: {
setActiveMenu(menu: string | null) {
this.activeMenu = menu;
this.currentMenu = menu;
},
pushNavigation(view: string) {
this.navigationStack.push(view);
},
popNavigation() {
this.navigationStack.pop();
setCurrentSubMenu(submenu: string | null) {
this.currentSubMenu = submenu;
},
},
});