fix(dashboard): Sort not working anymore (#1211)

This commit is contained in:
Rémi Marseault 2023-10-26 22:55:57 +02:00 committed by GitHub
parent ee03b5cb58
commit b2bbcb987e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import { SortOptions } from '@/constants/qbit/SortOptions'
import { formatData } from '@/helpers' import { formatData } from '@/helpers'
import { useMaindataStore } from '@/stores/maindata' import { useMaindataStore } from '@/stores/maindata'
import { useVueTorrentStore } from '@/stores/vuetorrent' import { useVueTorrentStore } from '@/stores/vuetorrent'
import { GetTorrentPayload } from '@/types/qbit/payloads'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { computed, reactive, ref, watch } from 'vue' import { computed, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@ -65,6 +66,13 @@ export const useDashboardStore = defineStore(
} }
}) })
const getTorrentsPayload = computed<GetTorrentPayload>(() => {
return {
sort: sortOptions.isCustomSortEnabled ? SortOptions.DEFAULT : sortOptions.sortBy,
reverse: sortOptions.reverseOrder
}
})
function isTorrentInSelection(hash: string) { function isTorrentInSelection(hash: string) {
return selectedTorrents.value.includes(hash) return selectedTorrents.value.includes(hash)
} }
@ -141,7 +149,8 @@ export const useDashboardStore = defineStore(
spanTorrentSelection, spanTorrentSelection,
selectAllTorrents, selectAllTorrents,
unselectAllTorrents, unselectAllTorrents,
toggleSelect toggleSelect,
getTorrentsPayload
} }
}, },
{ {

View file

@ -163,7 +163,7 @@ export const useMaindataStore = defineStore('maindata', () => {
// fetch torrent data // fetch torrent data
dashboardStore.sortOptions.isCustomSortEnabled = torrentBuilder.computedValues.indexOf(dashboardStore.sortOptions.sortBy) !== -1 dashboardStore.sortOptions.isCustomSortEnabled = torrentBuilder.computedValues.indexOf(dashboardStore.sortOptions.sortBy) !== -1
let data = await qbit.getTorrents() let data = await qbit.getTorrents(dashboardStore.getTorrentsPayload)
if (vueTorrentStore.showTrackerFilter) { if (vueTorrentStore.showTrackerFilter) {
trackers.value = data trackers.value = data