Skip to content

Commit

Permalink
fix: update temp js
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Oct 17, 2024
1 parent 3acd420 commit ba7c0ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions public/scripts/freshchat-temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const callDerivWS = async (hostname, params, token) => {
const ws = new WebSocket(wsUri);
let next_id = 1;
let requests = {};
let isAuthorized = false;

ws.addEventListener("error", (e) => {
ws.close();
Expand All @@ -68,17 +69,16 @@ const callDerivWS = async (hostname, params, token) => {
if (typeof data === "object") {
let jsonStr = data.data;
let json = JSON.parse(jsonStr);
if (typeof json === "object" && "authorize" in json) {
send(params);
return;
if (typeof json === "object" && "authorize" in json && !isAuthorized) {
isAuthorized = true; // Prevents reauthorization
send(params); // Send params after first authorization
} else {
resolve(json);
ws.close();
return;
}
} else {
reject("Unexpected message from deriv WS " + hostname);
}

reject("Unexpected message from deriv WS " + this.hostname);
});
});
};
Expand Down Expand Up @@ -132,7 +132,7 @@ class FreshChat {
};

script.onload = function () {
if (jwt) {
if (jwt && jwt.trim() !== "") {
window.fcWidget?.user?.setProperties({
cf_user_jwt: jwt,
});
Expand Down

0 comments on commit ba7c0ef

Please sign in to comment.