mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
fix(champions): remove strange bahviors after sorting multiple times
This commit is contained in:
parent
3d4c969ea0
commit
ec6319ec3b
1 changed files with 15 additions and 9 deletions
|
|
@ -234,11 +234,8 @@ export default {
|
||||||
champions() {
|
champions() {
|
||||||
this.updateChampionsList()
|
this.updateChampionsList()
|
||||||
},
|
},
|
||||||
|
championsToDisplay() {
|
||||||
onlyMostPlayed() {
|
this.reApplySorts()
|
||||||
// Re-apply the current sorting
|
|
||||||
this.order *= -1
|
|
||||||
this.sortBy(this.sortProps)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -270,18 +267,27 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.championsToDisplay.sort((a, b) => {
|
this.championsToDisplay.sort((a, b) => {
|
||||||
const aProp = props.split('.').reduce((p, c) => p && p[c] || null, a)
|
const aProp = props.split('.').reduce((p, c) => p && p[c], a)
|
||||||
const bProp = props.split('.').reduce((p, c) => p && p[c] || null, b)
|
const bProp = props.split('.').reduce((p, c) => p && p[c], b)
|
||||||
let order = aProp > bProp ? this.order : this.order * -1
|
let order = typeof aProp === 'string' ? aProp.localeCompare(bProp) : aProp - bProp
|
||||||
|
|
||||||
|
if (this.order == -1)
|
||||||
|
order *= -1
|
||||||
|
|
||||||
// Revert order for rank and champion name
|
// Revert order for rank and champion name
|
||||||
if (props === 'index' || props === 'champion.name') {
|
if (props === 'index' || props === 'champion.name') {
|
||||||
order *= -1
|
order *= -1
|
||||||
}
|
}
|
||||||
return order
|
|
||||||
|
// Second sort by champion name
|
||||||
|
return order || a.champion.name.localeCompare(b.champion.name)
|
||||||
})
|
})
|
||||||
this.sortProps = props
|
this.sortProps = props
|
||||||
},
|
},
|
||||||
|
reApplySorts() {
|
||||||
|
this.order *= -1
|
||||||
|
this.sortBy(this.sortProps)
|
||||||
|
},
|
||||||
sortedClasses(props) {
|
sortedClasses(props) {
|
||||||
return {
|
return {
|
||||||
'sorted': this.sortProps === props,
|
'sorted': this.sortProps === props,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue