fix keyboard controls

This commit is contained in:
2023-05-01 15:47:32 +02:00
parent e155cb1013
commit 5f1611998a
+3 -4
View File
@@ -39,7 +39,6 @@ export default defineComponent({
data () { data () {
return { return {
sortingData: { direction: -1, argument: 'kills' as keyof Player | 'k/d' | 'avg_distance' }, sortingData: { direction: -1, argument: 'kills' as keyof Player | 'k/d' | 'avg_distance' },
playerIdList: [] as string[],
store: useKillStore() store: useKillStore()
} }
}, },
@@ -115,11 +114,11 @@ export default defineComponent({
if (!this.$props.playerHighlighted) return if (!this.$props.playerHighlighted) return
if (!Object.keys(values).includes(e.key)) return if (!Object.keys(values).includes(e.key)) return
e.preventDefault() e.preventDefault()
const index = this.playerIdList.indexOf(this.$props.playerHighlighted) const index = this.playerList.findIndex(e => e.id === this.$props.playerHighlighted)
let nextIndex = (index + values[e.key]) let nextIndex = (index + values[e.key])
if (nextIndex >= this.playerIdList.length) nextIndex = this.playerIdList.length - 1 if (nextIndex >= this.playerList.length) nextIndex = this.playerList.length - 1
if (nextIndex < 0) nextIndex = 0 if (nextIndex < 0) nextIndex = 0
this.$emit('highlightPlayer', this.playerIdList[nextIndex]) this.$emit('highlightPlayer', this.playerList[nextIndex].id)
}, },
updateSort (argument:string) { updateSort (argument:string) {
if (this.sortingData.argument === argument) { if (this.sortingData.argument === argument) {