From 1d2bec73178d593486b7601901d78df4e2409b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20T=C3=A4kker?= Date: Fri, 25 Sep 2026 21:26:58 +0200 Subject: [PATCH] Align search results with track rows --- app/components/Track/Row.vue | 100 ++++++++++++++------ app/pages/search.vue | 175 ++++++++++++++++++++++++++++++++++- 2 files changed, 243 insertions(+), 32 deletions(-) diff --git a/app/components/Track/Row.vue b/app/components/Track/Row.vue index 6814390..3404031 100644 --- a/app/components/Track/Row.vue +++ b/app/components/Track/Row.vue @@ -2,20 +2,26 @@ import type { DropdownMenuItem } from "~/ui/DropdownMenu.vue" interface TrackRowProps { - track: Track + track?: Track + entity?: { + type: "album" | "artist" + _id: string + name: string + file?: string + cover?: string + artists?: Artist[] + } index: number extendedInfo?: boolean showImage?: boolean queueMode?: boolean } -const { track, index, extendedInfo, showImage, queueMode } = - defineProps() +const props = defineProps() const emit = defineEmits<{ (e: "playAlbumAtIndex"): void }>() const hovering = ref(false) const { playAlbum, addToFrontOfQueue, addToQueue } = usePlayer() - const toast = useToast() const dropdownMenuItems: DropdownMenuItem[][] = [ @@ -24,14 +30,15 @@ const dropdownMenuItems: DropdownMenuItem[][] = [ label: "Play only this", icon: "lucide:play", onSelect() { - playAlbum([track]) + if (props.track) playAlbum([props.track]) }, }, { label: "Play next", icon: "lucide:list-start", onSelect() { - addToFrontOfQueue(track) + if (!props.track) return + addToFrontOfQueue(props.track) toast.show("Playing next") }, }, @@ -39,41 +46,56 @@ const dropdownMenuItems: DropdownMenuItem[][] = [ label: "Add to queue", icon: "lucide:list-end", onSelect() { - addToQueue(track) + if (!props.track) return + addToQueue(props.track) toast.show("Added to queue") }, }, ], ] -const durationFormatted = computed(() => - new Date(track.durationInSeconds * 1000).toISOString().slice(14, 19), -) +const durationFormatted = computed(() => { + if (!props.track) return "" + return new Date(props.track.durationInSeconds * 1000) + .toISOString() + .slice(14, 19) +}) -const artworkSrc = computed(() => GET_FILE(track.album.file)) +const artworkSrc = computed(() => { + if (props.track) return GET_FILE(props.track.album.file) + const file = props.entity?.file ?? props.entity?.cover + return file ? GET_FILE(file) : undefined +})