From e538b0d4d715d11492dcfd03c7930142bb075f13 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Sun, 10 Jul 2022 22:10:09 +0300 Subject: [PATCH] rewrite highlight track to use track.uniq_hash instead of trackid --- src/App.vue | 4 ++-- src/components/FolderView/SongList.vue | 14 +++++++------- src/components/shared/SongItem.vue | 2 +- src/contexts/track_context.ts | 2 +- src/interfaces.ts | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/App.vue b/src/App.vue index b5660dc7..34f63140 100644 --- a/src/App.vue +++ b/src/App.vue @@ -62,9 +62,9 @@ function removeHighlight(route: RouteLocationNormalized) { } router.afterEach((to, from) => { - const hid = to.query.highlight as string; + const h_hash = to.query.highlight as string; - if (hid) removeHighlight(to); + if (h_hash) removeHighlight(to); if (isSameRoute(to, from)) return; document.getElementById("acontent")?.scrollTo(0, 0); diff --git a/src/components/FolderView/SongList.vue b/src/components/FolderView/SongList.vue index 4a772b93..d95b06b1 100644 --- a/src/components/FolderView/SongList.vue +++ b/src/components/FolderView/SongList.vue @@ -10,7 +10,7 @@ @updateQueue="updateQueue" :isPlaying="queue.playing" :isCurrent="queue.currentid == track.trackid" - :isHighlighted="highlightid == track.trackid" + :isHighlighted="highlightid == track.uniq_hash" /> @@ -46,16 +46,16 @@ const route = useRoute(); const routename = route.name as string; const highlightid = ref(route.query.highlight as string); -function highlightTrack(trackid: string) { - focusElem(`track-${trackid}`, 400, "center"); +function highlightTrack(t_hash: string) { + focusElem(`track-${t_hash}`, 500, "center"); } onBeforeRouteUpdate(async (to, from) => { - const hid = to.query.highlight as string; - highlightid.value = hid as string; + const h_hash = to.query.highlight as string; + highlightid.value = h_hash as string; - if (hid) { - highlightTrack(hid as string); + if (h_hash) { + highlightTrack(h_hash); } }); diff --git a/src/components/shared/SongItem.vue b/src/components/shared/SongItem.vue index 37de8e65..9173e60f 100644 --- a/src/components/shared/SongItem.vue +++ b/src/components/shared/SongItem.vue @@ -8,7 +8,7 @@ highlighted: isHighlighted, }, ]" - v-bind:class="`track-${track.trackid}`" + v-bind:class="`track-${track.uniq_hash}`" @dblclick="emitUpdate(track)" @contextmenu="showContextMenu" > diff --git a/src/contexts/track_context.ts b/src/contexts/track_context.ts index 2953b19c..244d1842 100644 --- a/src/contexts/track_context.ts +++ b/src/contexts/track_context.ts @@ -90,7 +90,7 @@ export default async ( Router.push({ name: "FolderView", params: { path: track.folder }, - query: { highlight: track.trackid }, + query: { highlight: track.uniq_hash }, }); }, icon: "folder", diff --git a/src/interfaces.ts b/src/interfaces.ts index bea31fc3..119d9734 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -16,6 +16,7 @@ export interface Track { tracknumber?: number; disknumber?: number; index?: number; + uniq_hash: string; } export interface Folder { @@ -64,7 +65,7 @@ export interface Playlist { count?: number; lastUpdated?: string; thumb?: string; - duration?: number + duration?: number; } export interface Notif {