Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/message-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ export default class MessageDispatch extends EventTarget {
break;
case "load":
{
if (this.hubChannel.can("pin_objects") && this.hubChannel.signIn) {
if (this.hubChannel.can("pin_objects")) {
loadState(this.hubChannel, APP.world, args);
}
}
break;
case "clear":
{
if (this.hubChannel.can("pin_objects") && this.hubChannel.signIn) {
clearState(this.hubChannel, APP.world);
if (this.hubChannel.can("pin_objects")) {
clearState(APP.world);
}
}
break;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/entity-state-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ const TEST_ASSET_STATE =
"https://raw.githubusercontent.com/mozilla/hubs-sample-assets/main/Hubs%20Components/test_json/__NAME__";

export async function loadState(hubChannel: HubChannel, world: HubsWorld, state: string) {
clearState(world, hubChannel);
clearState(world);

const stateUrl = TEST_ASSET_STATE.replace("__NAME__", state);
console.log(stateUrl);

const resp = await fetch(stateUrl);
const entityStates: EntityStateList = await resp.json();
entityStates.data.forEach(entityState => {
Expand All @@ -251,7 +251,7 @@ export async function loadState(hubChannel: HubChannel, world: HubsWorld, state:
});
}

export function clearState(world: HubsWorld, hubChannel: HubChannel) {
export function clearState(world: HubsWorld) {
networkedQuery(world).forEach(eid => {
if (isNetworkInstantiated(eid) && isPinned(eid)) {
deleteTheDeletableAncestor(world, eid);
Expand Down