Skip to content

Commit

Permalink
Use alias to fix naming collision between react state and utility fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
Stalgia Grigg committed Jun 2, 2023
1 parent 8fcc847 commit aaa9df3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/components/pinnable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { addComponent, removeComponent } from "bitecs";

AFRAME.registerComponent("pinnable", {
schema: {
pinned: { default: false }
Expand Down
10 changes: 5 additions & 5 deletions src/react-components/room/object-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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")
);
Expand Down

0 comments on commit aaa9df3

Please sign in to comment.