2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="songResultsWrapper">
|
2022-04-15 17:00:08 +00:00
|
|
|
<ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
Showing Songs for <strong>{{ decodedQ }}</strong>
|
2022-04-15 17:00:08 +00:00
|
|
|
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-04-15 17:00:08 +00:00
|
|
|
<span v-if="meta.songCount">{{ pluralize(meta.songCount, 'song') }} • {{ meta.totalLength }}</span>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot: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-04-15 14:24:30 +00:00
|
|
|
:config="songListControlConfig"
|
|
|
|
:selectedSongs="selectedSongs"
|
2022-04-21 16:06:45 +00:00
|
|
|
:songs="songs"
|
2022-04-15 17:00:08 +00:00
|
|
|
@playAll="playAll"
|
|
|
|
@playSelected="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-04-21 18:12:11 +00:00
|
|
|
<SongList ref="songList" :items="songs" type="search-results" @press:enter="onPressEnter"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-21 16:06:45 +00:00
|
|
|
import { computed, defineAsyncComponent, toRef, toRefs } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { searchStore } from '@/stores'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useSongList } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { pluralize } from '@/utils'
|
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
|
|
|
|
|
|
|
const props = defineProps<{ q: string }>()
|
|
|
|
const { q } = toRefs(props)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
|
|
|
ControlsToggler,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
|
|
|
meta,
|
|
|
|
selectedSongs,
|
|
|
|
showingControls,
|
|
|
|
songListControlConfig,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
2022-04-21 16:06:45 +00:00
|
|
|
} = useSongList(toRef(searchStore.state, 'songs'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const decodedQ = computed(() => decodeURIComponent(q.value))
|
|
|
|
|
|
|
|
searchStore.resetSongResultState()
|
|
|
|
searchStore.songSearch(decodedQ.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|