From c424c67d07f317ef4e43827e4ca6eee6f3959609 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Mon, 7 Jun 2021 09:21:33 +0200 Subject: [PATCH] Revert "Fix: don't display Intercom in Safe Apps (#2365)" This reverts commit 07465a0b2957fe7c9759815dc5b61de521a6e9a6. --- src/components/CookiesBanner/index.tsx | 11 ++--------- src/logic/hooks/useSafeAppUrl.tsx | 22 ---------------------- src/routes/safe/components/Apps/index.tsx | 14 ++++++++++---- 3 files changed, 12 insertions(+), 35 deletions(-) delete mode 100644 src/logic/hooks/useSafeAppUrl.tsx diff --git a/src/components/CookiesBanner/index.tsx b/src/components/CookiesBanner/index.tsx index 8b64d66e1f..2bae191676 100644 --- a/src/components/CookiesBanner/index.tsx +++ b/src/components/CookiesBanner/index.tsx @@ -9,7 +9,6 @@ import { COOKIES_KEY } from 'src/logic/cookies/model/cookie' import { openCookieBanner } from 'src/logic/cookies/store/actions/openCookieBanner' import { cookieBannerOpen } from 'src/logic/cookies/store/selectors' import { loadFromCookie, saveCookie } from 'src/logic/cookies/utils' -import { useSafeAppUrl } from 'src/logic/hooks/useSafeAppUrl' import { mainFontFamily, md, primary, screenSm } from 'src/theme/variables' import { loadGoogleAnalytics, removeCookies } from 'src/utils/googleAnalytics' import { closeIntercom, isIntercomLoaded, loadIntercom } from 'src/utils/intercom' @@ -98,7 +97,7 @@ interface CookiesBannerFormProps { const CookiesBanner = (): ReactElement => { const classes = useStyles() const dispatch = useRef(useDispatch()) - const { url: appUrl } = useSafeAppUrl() + const [showAnalytics, setShowAnalytics] = useState(false) const [showIntercom, setShowIntercom] = useState(false) const [localNecessary, setLocalNecessary] = useState(true) @@ -107,12 +106,6 @@ const CookiesBanner = (): ReactElement => { const showBanner = useSelector(cookieBannerOpen) - useEffect(() => { - if (appUrl) { - setTimeout(closeIntercom, 50) - } - }, [appUrl]) - useEffect(() => { async function fetchCookiesFromStorage() { const cookiesState = await loadFromCookie(COOKIES_KEY) @@ -178,7 +171,7 @@ const CookiesBanner = (): ReactElement => { dispatch.current(openCookieBanner({ cookieBannerOpen: false })) } - if (showIntercom && !appUrl) { + if (showIntercom) { loadIntercom() } diff --git a/src/logic/hooks/useSafeAppUrl.tsx b/src/logic/hooks/useSafeAppUrl.tsx deleted file mode 100644 index fa6b93f49b..0000000000 --- a/src/logic/hooks/useSafeAppUrl.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { useLocation } from 'react-router-dom' -import { useEffect, useState } from 'react' - -type AppUrlReturnType = { - url: string | null -} - -export const useSafeAppUrl = (): AppUrlReturnType => { - const [url, setUrl] = useState(null) - const { search } = useLocation() - - useEffect(() => { - if (search !== url) { - const query = new URLSearchParams(search) - setUrl(query.get('appUrl')) - } - }, [search, url]) - - return { - url, - } -} diff --git a/src/routes/safe/components/Apps/index.tsx b/src/routes/safe/components/Apps/index.tsx index 25b2858822..5fa825c03e 100644 --- a/src/routes/safe/components/Apps/index.tsx +++ b/src/routes/safe/components/Apps/index.tsx @@ -1,14 +1,20 @@ import React from 'react' -import { useSafeAppUrl } from 'src/logic/hooks/useSafeAppUrl' + +import { useLocation } from 'react-router-dom' import AppFrame from './components/AppFrame' import AppsList from './components/AppsList' +const useQuery = () => { + return new URLSearchParams(useLocation().search) +} + const Apps = (): React.ReactElement => { - const { url } = useSafeAppUrl() + const query = useQuery() + const appUrl = query.get('appUrl') - if (url) { - return + if (appUrl) { + return } else { return }