fix(search): fix pagination

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2457>
This commit is contained in:
Kasper Seweryn 2023-06-11 11:29:30 +02:00 committed by Marge
parent a26b29d434
commit d8d3de23ca
2 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1 @@
Fix pagination on search page (#2134)

View File

@ -31,7 +31,8 @@ syncRef(pageQuery, page, {
transform: { transform: {
ltr: (left) => +left, ltr: (left) => +left,
rtl: (right) => right.toString() rtl: (right) => right.toString()
} },
direction: 'both'
}) })
const q = useRouteQuery('q', '') const q = useRouteQuery('q', '')
@ -113,7 +114,7 @@ const currentType = computed(() => types.value.find(({ id }) => id === type.valu
const axiosParams = computed(() => { const axiosParams = computed(() => {
const params = new URLSearchParams({ const params = new URLSearchParams({
q: query.value, q: query.value,
page: page.value as unknown as string, page: pageQuery.value,
page_size: paginateBy.value as unknown as string page_size: paginateBy.value as unknown as string
}) })
@ -171,10 +172,12 @@ const search = async () => {
} }
watch(type, () => { watch(type, () => {
if (page.value === 1) return search()
page.value = 1 page.value = 1
search()
}) })
// NOTE: When we watch `page`, the `pageQuery` value is never updated for some reason
watch(pageQuery, search)
search() search()
const labels = computed(() => ({ const labels = computed(() => ({