Skip to content

Commit

Permalink
carol/Derivgo link (binary-com#6445)
Browse files Browse the repository at this point in the history
* use platform from query params to set app id

* add: check
  • Loading branch information
carolsachdeva committed Sep 16, 2022
1 parent 8f6d6f8 commit 9ec3655
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/shared/src/utils/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const domain_app_ids = {
'binary.com': 1,
};

export const platform_app_ids = {
derivgo: 23789,
};

export const getCurrentProductionDomain = () =>
!/^staging\./.test(window.location.hostname) &&
Object.keys(domain_app_ids).find(domain => window.location.hostname === domain);
Expand All @@ -43,8 +47,12 @@ export const getAppId = () => {
const user_app_id = ''; // you can insert Application ID of your registered application here
const config_app_id = window.localStorage.getItem('config.app_id');
const current_domain = getCurrentProductionDomain();
const platform = new URLSearchParams(window.location.search).get('platform');

if (config_app_id) {
// Added platform at the top since this should take precedence over the config_app_id
if (platform && platform_app_ids[platform]) {
app_id = platform_app_ids[platform];
} else if (config_app_id) {
app_id = config_app_id;
} else if (user_app_id.length) {
window.localStorage.setItem('config.default_app_id', user_app_id);
Expand All @@ -58,6 +66,7 @@ export const getAppId = () => {
window.localStorage.removeItem('config.default_app_id');
app_id = (isBot() ? 19111 : domain_app_ids[current_domain]) || 16929;
}

return app_id;
};

Expand Down

0 comments on commit 9ec3655

Please sign in to comment.