Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrienne / Remove any references to localstorage-sync #893

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions src/javascript/_common/base/client_base.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const moment = require('moment');
const isCryptocurrency = require('./currency_base').isCryptocurrency;
const SocketCache = require('./socket_cache');
const AuthClient = require('../auth');
const localize = require('../localize').localize;
const LocalStore = require('../storage').LocalStore;
const State = require('../storage').State;
const getPropertyValue = require('../utility').getPropertyValue;
const isEmptyObject = require('../utility').isEmptyObject;
const getAllowedLocalStorageOrigin = require('../url').getAllowedLocalStorageOrigin;

const ClientBase = (() => {
const storage_key = 'client.accounts';
let client_object = {};
let total_balance = {};
let current_loginid;
let has_readystate_listener = false;

const init = () => {
current_loginid = LocalStore.get('active_loginid');
Expand Down Expand Up @@ -42,7 +39,6 @@ const ClientBase = (() => {
*/
const set = (key, value, loginid = current_loginid) => {
if (key === 'loginid' && value !== current_loginid) {
syncWithDerivApp(value, client_object);
LocalStore.set('active_loginid', value);
current_loginid = value;
} else {
Expand All @@ -53,7 +49,6 @@ const ClientBase = (() => {
return;
}
client_object[loginid][key] = value;
syncWithDerivApp(loginid, client_object);
LocalStore.setObject(storage_key, client_object);
}
};
Expand Down Expand Up @@ -489,54 +484,6 @@ const ClientBase = (() => {
return false;
};

const syncWithDerivApp = (active_loginid, client_accounts) => {
// If the OAuth2 new authentication is enabled, all apps should not use localstorage-sync anymore
const isOAuth2Enabled = AuthClient.isOAuth2Enabled();
if (isOAuth2Enabled) return;
const iframe_window = document.getElementById('localstorage-sync');
const origin = getAllowedLocalStorageOrigin();

if (!iframe_window || !origin) return;

if (document.readyState === 'complete'){
iframe_window.onload = () => {
// Keep client.accounts in sync (in case user wasn't logged in).
if (iframe_window.src === `${origin}/localstorage-sync.html`) {
iframe_window.contentWindow.postMessage({
key : 'client.accounts',
value: JSON.stringify(client_accounts),
}, origin);
iframe_window.contentWindow.postMessage({
key : 'active_loginid',
value: active_loginid,
}, origin);
}
};

return;
}

if (!has_readystate_listener){
has_readystate_listener = true;

document.addEventListener('readystatechange', () => {
iframe_window.onload = () => {
// Keep client.accounts in sync (in case user wasn't logged in).
if (iframe_window.src === `${origin}/localstorage-sync.html`) {
iframe_window.contentWindow.postMessage({
key : 'client.accounts',
value: JSON.stringify(client_accounts),
}, origin);
iframe_window.contentWindow.postMessage({
key : 'active_loginid',
value: active_loginid,
}, origin);
}
};
});
}
};

return {
init,
isLoggedIn,
Expand Down
9 changes: 0 additions & 9 deletions src/javascript/app/pages/trade/tradepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ const Defaults = require('./defaults');
const TradingEvents = require('./event');
const Price = require('./price');
const Process = require('./process');
const AuthClient = require('../../../_common/auth');
const ViewPopup = require('../user/view_popup/view_popup');
const Client = require('../../base/client');
const Header = require('../../base/header');
const BinarySocket = require('../../base/socket');
const DerivBanner = require('../../common/deriv_banner');
const TopUpVirtualPopup = require('../user/account/top_up_virtual/pop_up');
const State = require('../../../_common/storage').State;
const getAllowedLocalStorageOrigin = require('../../../_common/url').getAllowedLocalStorageOrigin;
const LoaderElement = require('../loader.jsx');

const TradePage = (() => {
Expand All @@ -24,14 +22,7 @@ const TradePage = (() => {
LoaderElement.init();

const onLoad = () => {

const iframe_target_origin = getAllowedLocalStorageOrigin();
const isOauthEnabled = AuthClient.isOAuth2Enabled();
BinarySocket.wait('authorize').then(() => {
if (iframe_target_origin && !isOauthEnabled) {
const el_iframe = document.getElementById('localstorage-sync');
if (el_iframe) el_iframe.src = `${iframe_target_origin}/localstorage-sync.html`;
}
init();
});
};
Expand Down
Loading