Skip to content

Commit

Permalink
Fix deletable
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Dec 4, 2023
1 parent ad05d74 commit f863046
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/react-components/room/object-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,25 @@ export function useRemoveObject(hubChannel, scene, object) {

const eid = object.eid;

let canBePinned = false;
if (shouldUseNewLoader()) {
const mediaRootEid = findAncestorWithComponent(APP.world, MediaLoader, object.eid);
canBePinned = canPinObject(APP.hubChannel, mediaRootEid);
} else {
const el = object.el;
if (el.components["media-loader"]) {
const { fileIsOwned, fileId } = el.components["media-loader"].data;
canBePinned = fileIsOwned || (fileId && getPromotionTokenForFile(fileId));
}
}

const canRemoveObject = !!(
scene.is("entered") &&
!isPlayer(object) &&
!isObjectPinned(APP.world, eid) &&
!hasComponent(APP.world, Static, eid) &&
hubChannel.can("spawn_and_move_media")
hubChannel.can("spawn_and_move_media") &&
canBePinned
);

return { removeObject, canRemoveObject };
Expand Down

0 comments on commit f863046

Please sign in to comment.