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

Nuzhy/_/intercom by default #17915

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions packages/components/src/components/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions packages/hooks/src/useIntercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading