fix(front): make favorites work again
This commit is contained in:
parent
7e268a748d
commit
5b7f5e6f97
|
@ -201,7 +201,7 @@ const hover = ref(false)
|
||||||
class="meta right floated column"
|
class="meta right floated column"
|
||||||
>
|
>
|
||||||
<human-duration
|
<human-duration
|
||||||
v-if="showDuration && track.uploads[0] && track.uploads[0].duration"
|
v-if="showDuration && track.uploads && track.uploads.length > 0 && track.uploads[0].duration"
|
||||||
:duration="track.uploads[0].duration"
|
:duration="track.uploads[0].duration"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -274,5 +274,6 @@ const updatePage = (page: number) => {
|
||||||
<style scoped>
|
<style scoped>
|
||||||
[table-header] > label {
|
[table-header] > label {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
|
align-self: center !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Header from '~/components/ui/Header.vue'
|
||||||
import Spacer from '~/components/ui/Spacer.vue'
|
import Spacer from '~/components/ui/Spacer.vue'
|
||||||
import Link from '~/components/ui/Link.vue'
|
import Link from '~/components/ui/Link.vue'
|
||||||
import Alert from '~/components/ui/Alert.vue'
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
|
import Pagination from '~/components/ui/Pagination.vue'
|
||||||
import Loader from '~/components/ui/Loader.vue'
|
import Loader from '~/components/ui/Loader.vue'
|
||||||
|
|
||||||
import useSharedLabels from '~/composables/locale/useSharedLabels'
|
import useSharedLabels from '~/composables/locale/useSharedLabels'
|
||||||
|
@ -62,15 +63,15 @@ const fetchFavorites = async () => {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
favorites: 'true',
|
|
||||||
page: page.value,
|
page: page.value,
|
||||||
page_size: paginateBy.value,
|
page_size: paginateBy.value,
|
||||||
ordering: orderingString.value
|
ordering: orderingString.value,
|
||||||
|
scope: store.state.auth.fullUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
const measureLoading = logger.time('Loading user favorites')
|
const measureLoading = logger.time('Loading user favorites')
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('tracks/', { params })
|
const response = await axios.get('favorites/tracks/', { params })
|
||||||
|
|
||||||
results.length = 0
|
results.length = 0
|
||||||
results.push(...response.data.results)
|
results.push(...response.data.results)
|
||||||
|
@ -90,8 +91,14 @@ const fetchFavorites = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(page, fetchFavorites)
|
onMounted(() => {
|
||||||
fetchFavorites()
|
fetchFavorites()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch([() => paginateBy, page],
|
||||||
|
() => fetchFavorites(),
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
onOrderingUpdate(() => {
|
onOrderingUpdate(() => {
|
||||||
page.value = 1
|
page.value = 1
|
||||||
|
@ -107,12 +114,8 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Layout
|
<Layout main stack no-gap align-left
|
||||||
v-title="labels.title"
|
v-title="labels.title"
|
||||||
main
|
|
||||||
stack
|
|
||||||
no-gap
|
|
||||||
align-left
|
|
||||||
>
|
>
|
||||||
<Header :h1="labels.title">
|
<Header :h1="labels.title">
|
||||||
<template #action>
|
<template #action>
|
||||||
|
@ -123,7 +126,7 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
</template>
|
</template>
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<Loader v-if="isLoading" />
|
<Loader v-if="isLoading"/>
|
||||||
<Layout
|
<Layout
|
||||||
v-if="store.state.favorites.count > 0"
|
v-if="store.state.favorites.count > 0"
|
||||||
form
|
form
|
||||||
|
@ -131,16 +134,8 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
:class="['ui', { 'loading': isLoading }, 'form']"
|
:class="['ui', { 'loading': isLoading }, 'form']"
|
||||||
>
|
>
|
||||||
<Spacer :size="16" />
|
<Spacer :size="16" />
|
||||||
<Layout
|
<Layout flex style="justify-content: flex-end;">
|
||||||
flex
|
<Layout stack noGap label for="favorites-ordering">
|
||||||
style="justify-content: flex-end;"
|
|
||||||
>
|
|
||||||
<Layout
|
|
||||||
stack
|
|
||||||
no-gap
|
|
||||||
label
|
|
||||||
for="favorites-ordering"
|
|
||||||
>
|
|
||||||
<span class="label">
|
<span class="label">
|
||||||
{{ t('components.favorites.List.ordering.label') }}
|
{{ t('components.favorites.List.ordering.label') }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -158,12 +153,7 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</Layout>
|
</Layout>
|
||||||
<Layout
|
<Layout stack noGap label for="favorites-ordering-direction">
|
||||||
stack
|
|
||||||
no-gap
|
|
||||||
label
|
|
||||||
for="favorites-ordering-direction"
|
|
||||||
>
|
|
||||||
<span class="label">
|
<span class="label">
|
||||||
{{ t('components.favorites.List.ordering.direction.label') }}
|
{{ t('components.favorites.List.ordering.direction.label') }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -180,12 +170,7 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</Layout>
|
</Layout>
|
||||||
<Layout
|
<Layout stack noGap label for="favorites-results">
|
||||||
stack
|
|
||||||
no-gap
|
|
||||||
label
|
|
||||||
for="favorites-results"
|
|
||||||
>
|
|
||||||
<span class="label">
|
<span class="label">
|
||||||
{{ t('components.favorites.List.pagination.results') }}
|
{{ t('components.favorites.List.pagination.results') }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -204,6 +189,12 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
</select>
|
</select>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
<Pagination
|
||||||
|
v-if="results && count > paginateBy"
|
||||||
|
v-model:page="page"
|
||||||
|
:pages="Math.ceil((count || 0) / paginateBy)"
|
||||||
|
style="grid-column: 1 / -1;"
|
||||||
|
/>
|
||||||
<TrackTable
|
<TrackTable
|
||||||
v-if="results"
|
v-if="results"
|
||||||
:search="true"
|
:search="true"
|
||||||
|
@ -212,18 +203,13 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
|
||||||
:tracks="results"
|
:tracks="results"
|
||||||
/>
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
<Alert
|
<Alert blue align-items="center"
|
||||||
v-else
|
v-else-if="!isLoading"
|
||||||
blue
|
|
||||||
align-items="center"
|
|
||||||
>
|
>
|
||||||
<i
|
<i class="bi bi-heartbreak-fill" style="font-size: 100px;" />
|
||||||
class="bi bi-heartbreak-fill"
|
|
||||||
style="font-size: 100px;"
|
|
||||||
/>
|
|
||||||
<Spacer />
|
<Spacer />
|
||||||
{{ t('components.favorites.List.empty.noFavorites') }}
|
{{ t('components.favorites.List.empty.noFavorites') }}
|
||||||
<Spacer :size="32" />
|
<Spacer :size="32"/>
|
||||||
<Link
|
<Link
|
||||||
to="/library"
|
to="/library"
|
||||||
solid
|
solid
|
||||||
|
|
Loading…
Reference in New Issue