From 36a06e5a675a192bd44cc065a4d3ce340c37aa26 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 27 Nov 2023 10:39:33 +0100 Subject: [PATCH] Check if channel has been created before updating the object menu --- src/bit-systems/object-menu.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bit-systems/object-menu.ts b/src/bit-systems/object-menu.ts index 20b0454df3..ac80388433 100644 --- a/src/bit-systems/object-menu.ts +++ b/src/bit-systems/object-menu.ts @@ -221,6 +221,7 @@ function handleHeldExit(world: HubsWorld, eid: EntityID, menuEid: EntityID) { } function updateVisibility(world: HubsWorld, menu: EntityID, frozen: boolean) { + if (!APP.hubChannel) return; let target = ObjectMenu.targetRef[menu]; const visible = !!(target && frozen) && (ObjectMenu.flags[menu] & ObjectMenuFlags.Visible) !== 0; @@ -243,8 +244,8 @@ function updateVisibility(world: HubsWorld, menu: EntityID, frozen: boolean) { const mediaLoader = findAncestorWithComponent(world, MediaContentBounds, target); target = mediaLoader ? mediaLoader : target; - const canISpawnMove = APP.hubChannel!.can("spawn_and_move_media"); - const canIPin = !!(target && canPin(APP.hubChannel!, target)); + const canISpawnMove = APP.hubChannel.can("spawn_and_move_media"); + const canIPin = !!(target && canPin(APP.hubChannel, target)); const isEntityPinned = isPinned(target); // Parent visibility doesn't block raycasting, so we must set each button to be invisible