Skip to content

Commit

Permalink
Put entity_state_api behind qs param
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshaughnessy committed Feb 4, 2023
1 parent 6e1e30b commit 7df9cf2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utils/entity-state-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import HubChannel from "./hub-channel";
import { queueEntityStateAsMessage } from "./listen-for-network-messages";
import { networkableComponents, schemas } from "./network-schemas";
import { CreateMessage, EntityID, NetworkID, StorableUpdateMessage } from "./networking-types";
import qsTruthy from "./qs_truthy";

export type EntityState = {
create_message: CreateMessage;
Expand Down Expand Up @@ -108,9 +109,14 @@ function push(hubChannel: HubChannel, command: HubChannelCommand, payload?: HubC
if (!localClientID) {
throw new Error("Cannot get/set entity states without a local client ID.");
}
return new Promise((resolve, reject) => {
hubChannel.channel.push(command, payload).receive("ok", resolve).receive("error", reject);
});
if (qsTruthy("entity_state_api")) {
return new Promise((resolve, reject) => {
hubChannel.channel.push(command, payload).receive("ok", resolve).receive("error", reject);
});
} else {
console.warn("Entity state API is inactive. Would have sent:", { command, payload });
return Promise.reject();
}
}

function listEntityStates(hubChannel: HubChannel) {
Expand Down

0 comments on commit 7df9cf2

Please sign in to comment.