From aaa9df37ad13fa21745797b2edbb7da395bc09d0 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 2 Jun 2023 10:35:48 -0400 Subject: [PATCH] Use alias to fix naming collision between react state and utility function --- src/components/pinnable.js | 2 -- src/react-components/room/object-hooks.js | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/pinnable.js b/src/components/pinnable.js index 94169be00c..ded6194643 100644 --- a/src/components/pinnable.js +++ b/src/components/pinnable.js @@ -1,5 +1,3 @@ -import { addComponent, removeComponent } from "bitecs"; - AFRAME.registerComponent("pinnable", { schema: { pinned: { default: false } diff --git a/src/react-components/room/object-hooks.js b/src/react-components/room/object-hooks.js index 7e56253e9e..1cc4861c6a 100644 --- a/src/react-components/room/object-hooks.js +++ b/src/react-components/room/object-hooks.js @@ -4,7 +4,7 @@ import { rotateInPlaceAroundWorldUp, affixToWorldUp } from "../../utils/three-ut import { getPromotionTokenForFile } from "../../utils/media-utils"; import { hasComponent } from "bitecs"; import { Static } from "../../bit-components"; -import { isPinned } from "../../bit-systems/networking"; +import { isPinned as getPinnedState } from "../../bit-systems/networking"; export function isMe(object) { return object.el.id === "avatar-rig"; @@ -28,7 +28,7 @@ export function getObjectUrl(object) { } export function usePinObject(hubChannel, scene, object) { - const [isPinned, setIsPinned] = useState(isPinned(object.el.eid)); + const [isPinned, setIsPinned] = useState(getPinnedState(object.el.eid)); const pinObject = useCallback(() => { const el = object.el; @@ -54,11 +54,11 @@ export function usePinObject(hubChannel, scene, object) { const el = object.el; function onPinStateChanged() { - setIsPinned(isPinned(el.eid)); + setIsPinned(getPinnedState(el.eid)); } el.addEventListener("pinned", onPinStateChanged); el.addEventListener("unpinned", onPinStateChanged); - setIsPinned(isPinned(el.eid)); + setIsPinned(getPinnedState(el.eid)); return () => { el.removeEventListener("pinned", onPinStateChanged); el.removeEventListener("unpinned", onPinStateChanged); @@ -122,7 +122,7 @@ export function useRemoveObject(hubChannel, scene, object) { const canRemoveObject = !!( scene.is("entered") && !isPlayer(object) && - !isPinned(el.eid) && + !getPinnedState(el.eid) && !hasComponent(APP.world, Static, el.eid) && hubChannel.can("spawn_and_move_media") );