Skip to content

Commit

Permalink
fix: sonar cloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aswathy-deriv committed Feb 29, 2024
1 parent 2009c0b commit 2f71676
Showing 1 changed file with 64 additions and 21 deletions.
85 changes: 64 additions & 21 deletions src/common/websocket/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,89 @@ const isLive = () => isProduction() || isStaging() || isBeta()
const isLocalHost = () => isBrowser() && domain_config.local.hostname === window.location.hostname
const url = isBrowser() && window.location.href
const is_academy = isBrowser() && url.includes('academy')

// const getAppId = (): null | number | string => {
// let app_id = null
// const user_app_id = '' // you can insert Application ID of your registered application here
// const url_app_id = window.sessionStorage.getItem('app_id')
// const config_app_id = window.localStorage.getItem('config.app_id')

// if (isBrowser()) {
// const url_params = new URLSearchParams(window.location.search || '')
// const url_param_app_id = url_params.get('app_id')
// if (url_param_app_id) {
// window.sessionStorage.setItem('app_id', url_param_app_id)
// }

// if (is_academy) {
// app_id = 37228
// } else {
// if (url_app_id) {
// app_id = url_app_id
// } else if (config_app_id) {
// app_id = config_app_id
// } else if (isStaging()) {
// window.localStorage.removeItem('config.default_app_id')
// app_id = domain_config.staging.app_id
// } else if (isBeta()) {
// window.localStorage.removeItem('config.default_app_id')
// app_id = domain_config.beta.app_id
// } else if (user_app_id.length) {
// window.localStorage.setItem('config.default_app_id', user_app_id) // it's being used in endpoint chrome extension - please do not remove
// app_id = user_app_id
// } else if (isLocalHost()) {
// app_id = domain_config.local.app_id
// } else {
// window.localStorage.removeItem('config.default_app_id')
// app_id = isProduction() ? prod_app_id : domain_config.test.app_id
// }
// }
// }
// return app_id
// }
const getAppId = (): null | number | string => {
let app_id = null
const user_app_id = '' // you can insert Application ID of your registered application here

if (isBrowser()) {
const url_params = new URLSearchParams(window.location.search || '')
const url_param_app_id = url_params.get('app_id')
let storage_app_id = null

if (url_param_app_id) {
window.sessionStorage.setItem('app_id', url_param_app_id)
storage_app_id = url_param_app_id
} else {
storage_app_id = window.sessionStorage.getItem('app_id')
}
const url_app_id = window.sessionStorage.getItem('app_id')

const config_app_id = window.localStorage.getItem('config.app_id')

if (is_academy) {
app_id = 37228
} else if (storage_app_id) {
app_id = storage_app_id
} else if (config_app_id) {
app_id = config_app_id
} else if (isStaging()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.staging.app_id
} else if (isBeta()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.beta.app_id
} else if (user_app_id.length) {
window.localStorage.setItem('config.default_app_id', user_app_id)
app_id = user_app_id
} else if (isLocalHost()) {
app_id = domain_config.local.app_id
} else {
if (url_app_id) {
app_id = url_app_id
} else if (config_app_id) {
app_id = config_app_id
} else if (isStaging()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.staging.app_id
} else if (isBeta()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.beta.app_id
} else if (user_app_id.length) {
window.localStorage.setItem('config.default_app_id', user_app_id) // it's being used in endpoint chrome extension - please do not remove
app_id = user_app_id
} else if (isLocalHost()) {
app_id = domain_config.local.app_id
} else {
window.localStorage.removeItem('config.default_app_id')
app_id = isProduction() ? prod_app_id : domain_config.test.app_id
}
window.localStorage.removeItem('config.default_app_id')
app_id = isProduction() ? prod_app_id : domain_config.test.app_id
}
}

return app_id
}

const getSocketURL = () => {
let server_url

Expand Down

0 comments on commit 2f71676

Please sign in to comment.