2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<ScreenBase>
|
|
|
|
<template #header>
|
|
|
|
<ScreenHeader layout="collapsed">
|
|
|
|
<span v-if="q">Searching for <span class="font-thin">{{ q }}</span></span>
|
|
|
|
<span v-else>Search</span>
|
|
|
|
</ScreenHeader>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div v-if="q" class="space-y-8">
|
2024-04-23 21:01:27 +00:00
|
|
|
<SongResultsBlock :query="q" :searching="searching" :songs="excerpt.songs" data-testid="song-excerpts" />
|
2024-04-04 22:20:42 +00:00
|
|
|
<ArtistResultsBlock :artists="excerpt.artists" :searching="searching" data-testid="artist-excerpts" />
|
|
|
|
<AlbumResultsBlock :albums="excerpt.albums" :searching="searching" data-testid="album-excerpts" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
2024-04-04 22:20:42 +00:00
|
|
|
|
|
|
|
<ScreenEmptyState v-else>
|
|
|
|
<template #icon>
|
|
|
|
<Icon :icon="faSearch" />
|
|
|
|
</template>
|
|
|
|
Find songs, artists, and albums,
|
|
|
|
<span class="secondary d-block">all in one place.</span>
|
|
|
|
</ScreenEmptyState>
|
|
|
|
</ScreenBase>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faSearch } from '@fortawesome/free-solid-svg-icons'
|
2022-09-15 09:07:25 +00:00
|
|
|
import { intersectionBy } from 'lodash'
|
2022-07-07 18:05:46 +00:00
|
|
|
import { ref, toRef } from 'vue'
|
2022-11-18 18:44:20 +00:00
|
|
|
import { eventBus } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { searchStore } from '@/stores'
|
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
|
|
import ScreenEmptyState from '@/components/ui/ScreenEmptyState.vue'
|
2024-04-04 22:20:42 +00:00
|
|
|
import ScreenBase from '@/components/screens/ScreenBase.vue'
|
|
|
|
import SongResultsBlock from '@/components/screens/search/SongExcerptResultsBlock.vue'
|
|
|
|
import ArtistResultsBlock from '@/components/screens/search/ArtistExcerptResultsBlock.vue'
|
|
|
|
import AlbumResultsBlock from '@/components/screens/search/AlbumExcerptResultsBlock.vue'
|
2022-10-08 10:54:25 +00:00
|
|
|
|
2022-05-09 11:12:06 +00:00
|
|
|
const excerpt = toRef(searchStore.state, 'excerpt')
|
2022-04-15 17:00:08 +00:00
|
|
|
const q = ref('')
|
2022-08-01 07:55:23 +00:00
|
|
|
const searching = ref(false)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-09-15 09:07:25 +00:00
|
|
|
const doSearch = async () => {
|
2022-08-01 07:55:23 +00:00
|
|
|
searching.value = true
|
|
|
|
await searchStore.excerptSearch(q.value)
|
|
|
|
searching.value = false
|
2022-09-15 09:07:25 +00:00
|
|
|
}
|
|
|
|
|
2022-11-15 15:52:38 +00:00
|
|
|
eventBus.on('SEARCH_KEYWORDS_CHANGED', async _q => {
|
|
|
|
q.value = _q
|
|
|
|
await doSearch()
|
|
|
|
}).on('SONGS_DELETED', async songs => {
|
|
|
|
if (intersectionBy(songs, excerpt.value.songs, 'id').length !== 0) {
|
2022-09-15 09:07:25 +00:00
|
|
|
await doSearch()
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
|
|
|
</script>
|