From cf84eec999b2d86923cf3aba5f8b535b433b9b63 Mon Sep 17 00:00:00 2001 From: Erin Moon Date: Wed, 15 Apr 2020 15:05:25 -0500 Subject: [PATCH] components/video.vue: fix keyup-on-blur code the code authored in 52ee7372765e272aad7cb52b9dceecf9d0145f55 (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, which is more expressive anyway. --- client/src/components/video.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/components/video.vue b/client/src/components/video.vue index 65a91bc5..9bb8ba15 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -161,7 +161,7 @@ private observer = new ResizeObserver(this.onResise.bind(this)) private focused = false private fullscreen = false - private activeKeys: any = {} + private activeKeys: Set = new Set() get admin() { return this.$accessor.user.admin @@ -409,10 +409,9 @@ return } - let keys = Object.keys(this.activeKeys) - for(let key of keys) { + for (let key of this.activeKeys) { this.$client.sendData('keyup', { key }) - delete this.activeKeys[key] + this.activeKeys.delete(key) } } @@ -503,7 +502,7 @@ let key = this.getCode(e) this.$client.sendData('keydown', { key }) - this.activeKeys[key] = true + this.activeKeys.add(key) } onKeyUp(e: KeyboardEvent) { @@ -513,7 +512,7 @@ let key = this.getCode(e) this.$client.sendData('keyup', { key }) - delete this.activeKeys[key] + this.activeKeys.delete(key) } onResise() {