From deb9f37d8fd9653945ff234a7973d24fba341f9e Mon Sep 17 00:00:00 2001 From: Delirium Date: Fri, 1 Mar 2024 10:51:18 +0100 Subject: [PATCH] fix(ui): wrap some possible null values (#1922) --- .../app/player/web/managers/CanvasManager.ts | 18 +++++++++++------- .../src/main/modules/constructedStyleSheets.ts | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/app/player/web/managers/CanvasManager.ts b/frontend/app/player/web/managers/CanvasManager.ts index 03d417985..4d60a1bae 100644 --- a/frontend/app/player/web/managers/CanvasManager.ts +++ b/frontend/app/player/web/managers/CanvasManager.ts @@ -43,14 +43,18 @@ export default class CanvasManager { this.lastTs = t; const playTime = t - this.delta if (playTime > 0) { - const node = this.getNode(parseInt(this.nodeId, 10)) as unknown as VElement - const canvasCtx = (node.node as HTMLCanvasElement).getContext('2d'); - const canvasEl = node.node as HTMLVideoElement; - if (!this.videoTag.paused) { - void this.videoTag.pause() + const node = this.getNode(parseInt(this.nodeId, 10)) + if (node && node.node) { + const canvasCtx = (node.node as HTMLCanvasElement).getContext('2d'); + const canvasEl = node.node as HTMLVideoElement; + if (!this.videoTag.paused) { + void this.videoTag.pause() + } + this.videoTag.currentTime = playTime/1000; + canvasCtx?.drawImage(this.videoTag, 0, 0, canvasEl.width, canvasEl.height); + } else { + console.error(`CanvasManager: Node ${this.nodeId} not found`) } - this.videoTag.currentTime = playTime/1000; - canvasCtx?.drawImage(this.videoTag, 0, 0, canvasEl.width, canvasEl.height); } } } \ No newline at end of file diff --git a/tracker/tracker/src/main/modules/constructedStyleSheets.ts b/tracker/tracker/src/main/modules/constructedStyleSheets.ts index 7535fb161..2f4a6185a 100644 --- a/tracker/tracker/src/main/modules/constructedStyleSheets.ts +++ b/tracker/tracker/src/main/modules/constructedStyleSheets.ts @@ -52,7 +52,7 @@ export default function (app: App | null) { } const nowOwning: number[] = [] const styleSheets = root.adoptedStyleSheets - if (Symbol.iterator in styleSheets) { + if (styleSheets && Symbol.iterator in styleSheets) { for (const s of styleSheets) { let sheetID = styleSheetIDMap.get(s) const init = !sheetID