Skip to content

Commit

Permalink
Fixed spdermn02#33 in removeState do not check if state in `self.cu…
Browse files Browse the repository at this point in the history
…stomState`
  • Loading branch information
KillerBOSS2019 committed Aug 12, 2023
1 parent f0c8da4 commit 5bcee0d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class TouchPortalClient extends EventEmitter {
};
this.customStates[state.id] = state.desc;
} else if (`${stateType}` === "removeState") {
if (!this.customStates.hasOwnProperty(state.id)) {
this.logIt('ERROR', `removeState: Custom state of ${state.id} never created, so cannot remove it`);
throw new Error(`removeState: Custom state of ${state.id} never created, so cannot remove it`);
if (!state.id) {
this.logIt('ERROR', `removeState: ID parameter is empty`);
throw new Error(`removeState: ID parameter is empty`);
}
delete this.customStates[state.id];
}
Expand Down Expand Up @@ -109,10 +109,6 @@ class TouchPortalClient extends EventEmitter {
*/
removeState(id) {
// @ts-ignore
if (!id) {
this.logIt('ERROR', `removeState: ID parameter is empty`);
throw new Error(`removeState: ID parameter is empty`);
}
const stateArray = this.stateHelper({"id": id}, "removeState")
this.sendArray(stateArray)
}
Expand Down

0 comments on commit 5bcee0d

Please sign in to comment.