From 857c2484fedb00e903c23d8c039d525a571be6ce Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Fri, 10 Jun 2022 10:01:12 +0300 Subject: [PATCH] use computed properties to render correct nav title --- src/components/AlbumView/Header.vue | 2 + src/components/PlaylistView/Header.vue | 8 +++ src/components/nav/NavBar.vue | 71 ++++++++++++++------------ src/components/nav/Titles/APTitle.vue | 57 +++++++++++++++++++++ src/components/nav/Titles/Album.vue | 29 ----------- src/components/shared/Loader.vue | 2 +- src/composables/createSubPaths.ts | 15 +++--- src/stores/nav.ts | 22 ++++++-- 8 files changed, 131 insertions(+), 75 deletions(-) create mode 100644 src/components/nav/Titles/APTitle.vue delete mode 100644 src/components/nav/Titles/Album.vue diff --git a/src/components/AlbumView/Header.vue b/src/components/AlbumView/Header.vue index 166beb8f..3a649c21 100644 --- a/src/components/AlbumView/Header.vue +++ b/src/components/AlbumView/Header.vue @@ -53,6 +53,8 @@ const imguri = paths.images.thumb; const nav = useNavStore(); useVisibility(albumheaderthing, nav.toggleShowPlay); + + diff --git a/src/components/nav/Titles/Album.vue b/src/components/nav/Titles/Album.vue deleted file mode 100644 index fcebe531..00000000 --- a/src/components/nav/Titles/Album.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - - - diff --git a/src/components/shared/Loader.vue b/src/components/shared/Loader.vue index ac4affc9..d72a6818 100644 --- a/src/components/shared/Loader.vue +++ b/src/components/shared/Loader.vue @@ -7,7 +7,7 @@ - diff --git a/src/composables/createSubPaths.ts b/src/composables/createSubPaths.ts index 96105937..2f94d9b0 100644 --- a/src/composables/createSubPaths.ts +++ b/src/composables/createSubPaths.ts @@ -6,20 +6,19 @@ import { subPath } from "@/interfaces"; * @param {string} oldpath the old path to compare with the new path. */ export default function createSubPaths( - newpath: string | string[], - oldpath: string | string[] + newpath: string, + oldpath: string ): [string, subPath[]] { if (oldpath === undefined) oldpath = ""; - newpath = newpath as string; - oldpath = oldpath as string; - const newlist = newpath.split("/"); - newlist.shift(); + + if (newlist[0] == "$home") { + newlist.shift(); + } if (oldpath.includes(newpath)) { const oldlist = oldpath.split("/"); - oldlist.shift(); const current = newlist.slice(-1)[0]; return [oldpath, createSubs(oldlist, current)]; @@ -34,7 +33,7 @@ export default function createSubPaths( return { active: false, name: path, - path: newlist.slice(0, index + 1).join("/"), + path: list.slice(0, index + 1).join("/"), }; }); paths.reverse(); diff --git a/src/stores/nav.ts b/src/stores/nav.ts index faed7d02..7b2d2aa6 100644 --- a/src/stores/nav.ts +++ b/src/stores/nav.ts @@ -1,12 +1,26 @@ +import { playSources } from "@/composables/enums"; import { defineStore } from "pinia"; -export default defineStore("navmanagement", { +export default defineStore("navstore", { state: () => ({ - showPlay: false, + /** + * Page header visibility status. + */ + h_visible: false, + title: { + text: "", + store: null, + source: playSources, + }, }), actions: { - toggleShowPlay(state: boolean) { - this.showPlay = state; + /** + * Toggles the store value of the page header visibility. + * + * @param {boolean} state The visibility state of the page header. + */ + toggleShowPlay(state: boolean): void { + this.h_visible = state; }, }, });