Skip to content

Commit

Permalink
Add all the message types in one handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos Nikolaidis authored and goncalorolo committed Feb 13, 2023
1 parent 75b111d commit 30e368e
Showing 1 changed file with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,10 @@ export class SmartclideTdReusabilityTheiaWidget extends ReactWidget {
console.log("td-reusability: RECEIVED", JSON.stringify(data, undefined, 4));
window.removeEventListener("message", this.handleTokenInfo);
break;
default:
break;
}
}

//Handle one time COMM_START_REPLY message from parent
handleCommStart = ({data}:any) => {
switch (data.type) {
case messageTypes.COMM_START_REPLY:
console.log("td-reusability: RECEIVED", JSON.stringify(data, undefined, 4));
SmartclideTdReusabilityTheiaWidget.state.stateKeycloakToken = data.content.token;
SmartclideTdReusabilityTheiaWidget.state.stateServiceID = data.content.serviceID;
window.removeEventListener("message", this.handleCommStart);
break;
default:
break;
Expand All @@ -106,9 +97,6 @@ export class SmartclideTdReusabilityTheiaWidget extends ReactWidget {
//Add even listener to get the Keycloak Token
window.addEventListener("message", this.handleTokenInfo);

//Add even listener to get the Keycloak Token and Service id on start
window.addEventListener("message", this.handleCommStart);

//Send a message to inform SmartCLIDE IDE
let message = buildMessage(messageTypes.COMM_START);
window.parent.postMessage(message, "*");
Expand Down

0 comments on commit 30e368e

Please sign in to comment.