Correctly sort

This commit is contained in:
Chocobozzz 2020-09-02 11:37:02 +02:00
parent 367d52974a
commit 349c8c7788
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 15 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -415,7 +415,7 @@
currentPage: 1,
pages: [],
resultsPerVideosPage: 10,
resultsPerChannelsPage: 5,
resultsPerChannelsPage: 3,
displayFilters: false,
oldQuery: '',
@ -610,12 +610,14 @@
this.resultsCount = videosResult.total + channelsResult.total
this.results = channelsResult.data.concat(videosResult.data)
this.results.sort((r1, r2) => {
if (r1.score < r2.score) return -1
else if (r1.score === r2.score) return 0
if (this.formSort === '-match') {
this.results.sort((r1, r2) => {
if (r1.score < r2.score) return 1
else if (r1.score === r2.score) return 0
return -1
})
return -1
})
}
this.buildPages()
this.searchDone = true
@ -705,9 +707,15 @@
buildChannelSearchQuery () {
const { start, count } = pageToAPIParams(this.currentPage, this.resultsPerChannelsPage)
let sort: string
if (this.formSort === '-matched') sort = '-matched'
else if (this.formSort === '-publishedAt') sort = '-createdAt'
else if (this.formSort === 'publishedAt') sort = 'createdAt'
return {
search: this.formSearch,
start,
sort,
count
} as VideoChannelsSearchQuery
},