Skip to content

Commit

Permalink
fix: condition to check fcWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Nov 21, 2024
1 parent 4028954 commit dc5ee8e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
11 changes: 8 additions & 3 deletions public/scripts/freshchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ class FreshChat {

script.onload = function () {
if (jwt) {
window.fcWidget?.user?.setProperties({
cf_user_jwt: jwt,
});
const checkWidget = setInterval(() => {
if (window.fcWidget?.user) {
window.fcWidget.user?.setProperties({
cf_user_jwt: jwt,
});
clearInterval(checkWidget);
}
}, 500);
}
};
};
Expand Down
19 changes: 14 additions & 5 deletions public/scripts/freshchat/v1.0.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ class FreshChat {
constructor({ token = null, hideButton = false } = {}) {
this.authToken = token;
this.hideButton = hideButton;
const config_url = localStorage.getItem("config.server_url")?.replace(/^['"]+|['"]+$/g, "");
const config_appID = localStorage.getItem("config.app_id")?.replace(/^['"]+|['"]+$/g, "");
const config_url = localStorage
.getItem("config.server_url")
?.replace(/^['"]+|['"]+$/g, "");
const config_appID = localStorage
.getItem("config.app_id")
?.replace(/^['"]+|['"]+$/g, "");
this.hostname =
config_url && config_url.trim() !== "" ? config_url : "green.derivws.com";
this.appId =
Expand Down Expand Up @@ -81,9 +85,14 @@ class FreshChat {

script.onload = function () {
if (jwt) {
window.fcWidget?.user?.setProperties({
cf_user_jwt: jwt,
});
const checkWidget = setInterval(() => {
if (window.fcWidget?.user) {
window.fcWidget.user?.setProperties({
cf_user_jwt: jwt,
});
clearInterval(checkWidget);
}
}, 500);
}
};
};
Expand Down
11 changes: 8 additions & 3 deletions public/scripts/freshchat/v1.0.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ class FreshChat {

script.onload = function () {
if (jwt) {
window.fcWidget?.user?.setProperties({
cf_user_jwt: jwt,
});
const checkWidget = setInterval(() => {
if (window.fcWidget?.user) {
window.fcWidget.user?.setProperties({
cf_user_jwt: jwt,
});
clearInterval(checkWidget);
}
}, 500);
}
};
};
Expand Down

0 comments on commit dc5ee8e

Please sign in to comment.