Skip to content

Commit

Permalink
fix: default appID, config values check
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Nov 6, 2024
1 parent f8019a7 commit de0c192
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions public/scripts/freshchat-temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ const DOMAIN_LIST_APP_ID = {

const getAppID = () => {
const host = window.location.hostname;
return DOMAIN_LIST_APP_ID[host] || null;
return DOMAIN_LIST_APP_ID[host] || "16929";
};

class FreshChat {
constructor({ token = null, hideButton = false } = {}) {
this.authToken = token;
this.hideButton = hideButton;
this.hostname = localStorage.getItem("config.server_url") || "green.derivws.com";
this.appId = localStorage.getItem("config.app_id") || getAppID();
const config_url = localStorage.getItem("config.server_url");
const config_appID = localStorage.getItem("config.app_id");
this.hostname = config_url && config_url.trim() !== "" ? config_url : "green.derivws.com";
this.appId = config_appID && config_appID.trim() !== "" ? config_appID : getAppID();
this.init();
}

Expand All @@ -43,7 +45,7 @@ class FreshChat {

init = async () => {
let jwt = null;
if (this.authToken && this.appId) {
if (this.authToken) {
jwt = await this.fetchJWTToken({
token: this.authToken,
appId: this.appId,
Expand Down

0 comments on commit de0c192

Please sign in to comment.