From b8166c3efce7006d85b0897d1dfe9b26ae34e4fc Mon Sep 17 00:00:00 2001
From: Sui Sin <103026762+suisin-deriv@users.noreply.github.com>
Date: Wed, 15 Jan 2025 14:35:30 +0800
Subject: [PATCH] chore: change to check and trading hub instead of or (#17975)
---
.../src/App/Components/Layout/Header/platform-dropdown.jsx | 4 ++--
.../AccountSwitcherWallet/account-switcher-wallet-mobile.tsx | 2 +-
.../AccountSwitcherWallet/account-switcher-wallet.tsx | 2 +-
.../core/src/App/Containers/RootComponent/root-component.jsx | 4 ++--
.../wallets/src/components/ModalProvider/ModalProvider.tsx | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/core/src/App/Components/Layout/Header/platform-dropdown.jsx b/packages/core/src/App/Components/Layout/Header/platform-dropdown.jsx
index daf5d2659828..08fe66855cfe 100644
--- a/packages/core/src/App/Components/Layout/Header/platform-dropdown.jsx
+++ b/packages/core/src/App/Components/Layout/Header/platform-dropdown.jsx
@@ -54,7 +54,7 @@ const PlatformDropdown = ({ app_routing_history, closeDrawer, platform_config, s
const { isDesktop } = useDevice();
const { isHubRedirectionEnabled } = useIsHubRedirectionEnabled();
const { client } = useStore();
- const { account_settings } = client;
+ const { account_settings, has_wallet } = client;
const { trading_hub } = account_settings;
const TradersHubRedirect = () => {
@@ -62,7 +62,7 @@ const PlatformDropdown = ({ app_routing_history, closeDrawer, platform_config, s
{
- if (isHubRedirectionEnabled || !!trading_hub) {
+ if (isHubRedirectionEnabled && has_wallet && !!trading_hub) {
window.location.assign(platforms.tradershub_os.url);
return;
}
diff --git a/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet-mobile.tsx b/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet-mobile.tsx
index cf77444b0fce..58c779b9cb11 100644
--- a/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet-mobile.tsx
+++ b/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet-mobile.tsx
@@ -30,7 +30,7 @@ export const AccountSwitcherWalletMobile = observer(({ is_visible, toggle, login
}, [toggle]);
const handleTradersHubRedirect = () => {
- if (isHubRedirectionEnabled || !!trading_hub) {
+ if (isHubRedirectionEnabled && !!trading_hub) {
window.location.assign(platforms.tradershub_os.url);
return;
}
diff --git a/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet.tsx b/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet.tsx
index 3c20521b8c60..7d042fede426 100644
--- a/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet.tsx
+++ b/packages/core/src/App/Containers/AccountSwitcherWallet/account-switcher-wallet.tsx
@@ -43,7 +43,7 @@ export const AccountSwitcherWallet = observer(({ is_visible, toggle }: TAccountS
useOnClickOutside(wrapper_ref, closeAccountsDialog, validateClickOutside);
const handleTradersHubRedirect = async () => {
- if (isHubRedirectionEnabled || !!trading_hub) {
+ if (isHubRedirectionEnabled && !!trading_hub) {
window.location.assign(platforms.tradershub_os.url);
return;
}
diff --git a/packages/core/src/App/Containers/RootComponent/root-component.jsx b/packages/core/src/App/Containers/RootComponent/root-component.jsx
index 8a1cfda5e7df..594e1ad624dc 100644
--- a/packages/core/src/App/Containers/RootComponent/root-component.jsx
+++ b/packages/core/src/App/Containers/RootComponent/root-component.jsx
@@ -39,7 +39,7 @@ const RootComponent = observer(props => {
const STAGING_REDIRECT_URL = 'https://staging-hub.deriv.com/tradershub/options';
useEffect(() => {
- if (((isHubRedirectionEnabled && has_wallet) || !!trading_hub) && !prevent_redirect_to_hub) {
+ if (isHubRedirectionEnabled && has_wallet && !!trading_hub && !prevent_redirect_to_hub) {
const redirectUrl = process.env.NODE_ENV === 'production' ? PRODUCTION_REDIRECT_URL : STAGING_REDIRECT_URL;
window.location.assign(redirectUrl);
}
@@ -53,7 +53,7 @@ const RootComponent = observer(props => {
}}
notificationMessagesUi={notification_messages_ui}
onWalletsOnboardingTourGuideCloseHandler={onWalletsOnboardingTourGuideCloseHandler}
- isHubRedirectionEnabled={isHubRedirectionEnabled || !!trading_hub}
+ isHubRedirectionEnabled={isHubRedirectionEnabled && !!trading_hub}
/>
) : (
diff --git a/packages/wallets/src/components/ModalProvider/ModalProvider.tsx b/packages/wallets/src/components/ModalProvider/ModalProvider.tsx
index 672ddb1af2ae..0d3b8c51de96 100644
--- a/packages/wallets/src/components/ModalProvider/ModalProvider.tsx
+++ b/packages/wallets/src/components/ModalProvider/ModalProvider.tsx
@@ -89,7 +89,7 @@ const ModalProvider = ({ children }: React.PropsWithChildren) => {
}));
// We need to add this check here because wallets account is coming from Low-Code tradershub.
// This condition is to reload the page when the modal is closed.
- if (isHubRedirectionEnabled || !!tradingHub) {
+ if (isHubRedirectionEnabled && !!tradingHub) {
window.location.reload();
}
};