Skip to content

Commit e4f5ab3

Browse files
chore: wait for store to be initialised
1 parent 3f15e54 commit e4f5ab3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/core/src/App/Containers/RootComponent/root-component.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const RootComponent = observer(props => {
2525
setIsWalletsOnboardingTourGuideVisible,
2626
notification_messages_ui,
2727
} = ui;
28-
const { has_wallet, logout, prevent_redirect_to_hub } = client;
28+
const { has_wallet, logout, prevent_redirect_to_hub, is_client_store_initialized } = client;
2929

3030
const { oAuthLogout } = useOauth2({ handleLogout: logout });
3131

@@ -38,19 +38,19 @@ const RootComponent = observer(props => {
3838
const STAGING_REDIRECT_URL = 'https://staging-hub.deriv.com/tradershub/home';
3939

4040
useEffect(() => {
41-
if (isHubRedirectionEnabled && has_wallet && !prevent_redirect_to_hub) {
41+
if (isHubRedirectionEnabled && has_wallet && !prevent_redirect_to_hub && is_client_store_initialized) {
4242
const redirectUrl = process.env.NODE_ENV === 'production' ? PRODUCTION_REDIRECT_URL : STAGING_REDIRECT_URL;
43+
// NOTE: Clear OIDC related local storage, this is to prevent OIDC to re-apply client.accounts again from the callback page
44+
localStorage.removeItem('config.account1');
45+
localStorage.removeItem('config.tokens');
4346
// NOTE: Clear local storage to prevent user from being logged in at Deriv.app since they should be logged in at low-code Traders Hub only
4447
localStorage.removeItem('active_loginid');
4548
localStorage.removeItem('active_user_id');
4649
localStorage.removeItem('client.accounts');
4750
localStorage.removeItem('active_wallet_loginid');
48-
// NOTE: Clear OIDC related local storage, this is to prevent OIDC to re-apply client.accounts again from the callback page
49-
localStorage.removeItem('config.account1');
50-
localStorage.removeItem('config.tokens');
5151
window.location.assign(redirectUrl);
5252
}
53-
}, [isHubRedirectionEnabled, has_wallet, prevent_redirect_to_hub]);
53+
}, [isHubRedirectionEnabled, has_wallet, prevent_redirect_to_hub, is_client_store_initialized]);
5454

5555
return has_wallet ? (
5656
<Wallets

0 commit comments

Comments
 (0)