components/video.vue: fix keyup-on-blur code

the code authored in 52ee737276 (probably)
worked in the browser due to string to numeric type autoconversion but
didn't typecheck during container build.

namely, Object.keys(this.activeKeys) will always return a string[];
however, we need number[] for the sendData() call to typecheck.

this replaces the untyped object holding active keys with a Set<number>,
which is more expressive anyway.
This commit is contained in:
Erin Moon 2020-04-15 15:05:25 -05:00
parent 40a9819253
commit cf84eec999

View File

@ -161,7 +161,7 @@
private observer = new ResizeObserver(this.onResise.bind(this)) private observer = new ResizeObserver(this.onResise.bind(this))
private focused = false private focused = false
private fullscreen = false private fullscreen = false
private activeKeys: any = {} private activeKeys: Set<number> = new Set()
get admin() { get admin() {
return this.$accessor.user.admin return this.$accessor.user.admin
@ -409,10 +409,9 @@
return return
} }
let keys = Object.keys(this.activeKeys) for (let key of this.activeKeys) {
for(let key of keys) {
this.$client.sendData('keyup', { key }) this.$client.sendData('keyup', { key })
delete this.activeKeys[key] this.activeKeys.delete(key)
} }
} }
@ -503,7 +502,7 @@
let key = this.getCode(e) let key = this.getCode(e)
this.$client.sendData('keydown', { key }) this.$client.sendData('keydown', { key })
this.activeKeys[key] = true this.activeKeys.add(key)
} }
onKeyUp(e: KeyboardEvent) { onKeyUp(e: KeyboardEvent) {
@ -513,7 +512,7 @@
let key = this.getCode(e) let key = this.getCode(e)
this.$client.sendData('keyup', { key }) this.$client.sendData('keyup', { key })
delete this.activeKeys[key] this.activeKeys.delete(key)
} }
onResise() { onResise() {