Correctly sort
This commit is contained in:
parent
367d52974a
commit
349c8c7788
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue