From d1002ab4a1ae464e41c71e44e045db491275fbd1 Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Tue, 31 Dec 2024 10:43:40 +0800 Subject: [PATCH] fix: intercom by default --- packages/components/src/components/icon/icons.js | 1 + .../App/Components/Elements/LiveChat/live-chat.tsx | 5 ++--- packages/hooks/src/useIntercom.ts | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/components/src/components/icon/icons.js b/packages/components/src/components/icon/icons.js index aacf358df0b5..84032db28505 100644 --- a/packages/components/src/components/icon/icons.js +++ b/packages/components/src/components/icon/icons.js @@ -640,6 +640,7 @@ import './common/ic-tour-guide-step2.svg'; import './common/ic-trade.svg'; import './common/ic-trading-view-chart.svg'; import './common/ic-transactions.svg'; +import './common/ic-triangle-exclamation-xl.svg'; import './common/ic-tutorials-tabs.svg'; import './common/ic-unarchive.svg'; import './common/ic-undo.svg'; diff --git a/packages/core/src/App/Components/Elements/LiveChat/live-chat.tsx b/packages/core/src/App/Components/Elements/LiveChat/live-chat.tsx index fc486fadabb1..7fe8ea3a6ba0 100644 --- a/packages/core/src/App/Components/Elements/LiveChat/live-chat.tsx +++ b/packages/core/src/App/Components/Elements/LiveChat/live-chat.tsx @@ -10,10 +10,9 @@ const LiveChat = observer(({ showPopover }: { showPopover?: boolean }) => { const { is_livechat_available } = useIsLiveChatWidgetAvailable(); - const fcAvailable = useIsFreshchatAvailable(); const icAvailable = useIsIntercomAvailable(); - const isNeitherChatNorLiveChatAvailable = !is_livechat_available && !fcAvailable && !icAvailable; + const isNeitherChatNorLiveChatAvailable = !is_livechat_available && !icAvailable; if (isNeitherChatNorLiveChatAvailable) { return null; @@ -22,7 +21,7 @@ const LiveChat = observer(({ showPopover }: { showPopover?: boolean }) => { // Quick fix for making sure livechat won't popup if feature flag is late to enable. // We will add a refactor after this setInterval(() => { - if (fcAvailable || icAvailable) { + if (icAvailable) { window.LiveChatWidget?.call('destroy'); } }, 10); diff --git a/packages/hooks/src/useIntercom.ts b/packages/hooks/src/useIntercom.ts index a3a235814d11..3b90fe1d59f6 100644 --- a/packages/hooks/src/useIntercom.ts +++ b/packages/hooks/src/useIntercom.ts @@ -8,14 +8,21 @@ export const useIntercom = (token: string | null) => { const [enable_intercom] = useGrowthbookGetFeatureValue({ featureFlag: 'enable_intercom', }); - const scriptStatus = useScript(enable_intercom ? intercom_script : null); + const scriptStatus = useScript(intercom_script); useEffect(() => { - if (!enable_intercom || scriptStatus !== 'ready' || !window?.DerivInterCom) return; + if (!enable_intercom || scriptStatus !== 'ready' || !window?.DerivInterCom) { + if (!enable_intercom && window.Intercom) { + console.log(`intercom shutdown`); + window.Intercom('shutdown'); + } + return; + } let intervalId: NodeJS.Timeout; const initIntercom = () => { + console.log(`intercom init`); window.DerivInterCom.initialize({ hideLauncher: true, token,