2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="songResultsWrapper">
|
2022-07-17 08:58:05 +00:00
|
|
|
<ScreenHeader :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
2022-07-16 15:44:45 +00:00
|
|
|
Songs for <span class="text-thin">{{ decodedQ }}</span>
|
2022-12-02 16:17:37 +00:00
|
|
|
<ControlsToggle v-model="showingControls" />
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #thumbnail>
|
|
|
|
<ThumbnailStack :thumbnails="thumbnails" />
|
2022-07-16 09:52:39 +00:00
|
|
|
</template>
|
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template v-if="songs.length" #meta>
|
2022-09-03 08:32:09 +00:00
|
|
|
<span>{{ pluralize(songs, 'song') }}</span>
|
2022-07-10 17:15:56 +00:00
|
|
|
<span>{{ duration }}</span>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #controls>
|
2022-04-15 17:00:08 +00:00
|
|
|
<SongListControls
|
2022-04-21 16:06:45 +00:00
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
2022-12-17 12:09:22 +00:00
|
|
|
@filter="applyFilter"
|
2022-12-02 16:17:37 +00:00
|
|
|
@play-all="playAll"
|
|
|
|
@play-selected="playSelected"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
</template>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<SongListSkeleton v-if="loading" />
|
|
|
|
<SongList v-else ref="songList" @sort="sort" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-10-08 10:54:25 +00:00
|
|
|
import { computed, onMounted, ref, toRef } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { searchStore } from '@/stores'
|
2022-11-18 18:44:20 +00:00
|
|
|
import { useRouter, useSongList } from '@/composables'
|
|
|
|
import { pluralize } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
2022-08-01 07:55:23 +00:00
|
|
|
import SongListSkeleton from '@/components/ui/skeletons/SongListSkeleton.vue'
|
2022-04-21 16:06:45 +00:00
|
|
|
|
2022-11-18 18:44:20 +00:00
|
|
|
const { getRouteParam } = useRouter()
|
2022-10-08 10:54:25 +00:00
|
|
|
const q = ref('')
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
2022-06-10 10:47:46 +00:00
|
|
|
ControlsToggle,
|
2022-07-16 09:52:39 +00:00
|
|
|
ThumbnailStack,
|
|
|
|
headerLayout,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
2022-07-16 09:52:39 +00:00
|
|
|
thumbnails,
|
2022-04-23 21:24:02 +00:00
|
|
|
duration,
|
2022-04-15 17:00:08 +00:00
|
|
|
showingControls,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
2022-12-17 12:09:22 +00:00
|
|
|
applyFilter,
|
2022-07-16 09:52:39 +00:00
|
|
|
sort,
|
|
|
|
onScrollBreakpoint
|
2022-11-12 21:38:31 +00:00
|
|
|
} = useSongList(toRef(searchStore.state, 'songs'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const decodedQ = computed(() => decodeURIComponent(q.value))
|
2022-08-01 07:55:23 +00:00
|
|
|
const loading = ref(false)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
searchStore.resetSongResultState()
|
2022-08-01 07:55:23 +00:00
|
|
|
|
|
|
|
onMounted(async () => {
|
2022-11-18 18:44:20 +00:00
|
|
|
q.value = getRouteParam('q') || ''
|
2022-10-08 10:54:25 +00:00
|
|
|
if (!q.value) return
|
|
|
|
|
2022-08-01 07:55:23 +00:00
|
|
|
loading.value = true
|
|
|
|
await searchStore.songSearch(q.value)
|
|
|
|
loading.value = false
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|