Fix tracks table fetching all tracks in some cases
This commit is contained in:
parent
9edc7f9548
commit
78854bbae3
|
@ -20,7 +20,7 @@ interface Events {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
tracks?: Track[]
|
tracks?: undefined | Track[]
|
||||||
|
|
||||||
showAlbum?: boolean
|
showAlbum?: boolean
|
||||||
showArtist?: boolean
|
showArtist?: boolean
|
||||||
|
@ -47,7 +47,7 @@ interface Props {
|
||||||
|
|
||||||
const emit = defineEmits<Events>()
|
const emit = defineEmits<Events>()
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
tracks: () => [],
|
tracks: undefined,
|
||||||
|
|
||||||
showAlbum: true,
|
showAlbum: true,
|
||||||
showArtist: true,
|
showArtist: true,
|
||||||
|
@ -87,7 +87,7 @@ const additionalTracks = ref([] as Track[])
|
||||||
const query = ref('')
|
const query = ref('')
|
||||||
|
|
||||||
const allTracks = computed(() => {
|
const allTracks = computed(() => {
|
||||||
const tracks = [...props.tracks, ...additionalTracks.value]
|
const tracks = [...(props.tracks ?? []), ...additionalTracks.value]
|
||||||
return props.unique
|
return props.unique
|
||||||
? uniqBy(tracks, 'id')
|
? uniqBy(tracks, 'id')
|
||||||
: tracks
|
: tracks
|
||||||
|
@ -133,7 +133,7 @@ const performSearch = () => {
|
||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.tracks.length === 0) {
|
if (props.tracks === undefined) {
|
||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,12 +251,12 @@ const updatePage = (page: number) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="paginateResults"
|
v-if="tracks && paginateResults"
|
||||||
class="ui center aligned basic segment desktop-and-up"
|
class="ui center aligned basic segment desktop-and-up"
|
||||||
>
|
>
|
||||||
<pagination
|
<pagination
|
||||||
:total="totalTracks"
|
:total="totalTracks"
|
||||||
:current=" tracks.length > 0 ? page : currentPage"
|
:current="tracks.length > 0 ? page : currentPage"
|
||||||
:paginate-by="paginateBy"
|
:paginate-by="paginateBy"
|
||||||
@update:current="updatePage"
|
@update:current="updatePage"
|
||||||
/>
|
/>
|
||||||
|
@ -289,7 +289,7 @@ const updatePage = (page: number) => {
|
||||||
:is-podcast="isPodcast"
|
:is-podcast="isPodcast"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="paginateResults && totalTracks > paginateBy"
|
v-if="tracks && paginateResults && totalTracks > paginateBy"
|
||||||
class="ui center aligned basic segment tablet-and-below"
|
class="ui center aligned basic segment tablet-and-below"
|
||||||
>
|
>
|
||||||
<pagination
|
<pagination
|
||||||
|
|
Loading…
Reference in New Issue