From e97d228429a006d33790860cdb17fa28bd1cae75 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Wed, 2 Jun 2021 11:58:46 +0200 Subject: [PATCH 1/2] Set v3.6.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07c32020..2f3a95ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "3.6.6", + "version": "3.6.7", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": { From 07465a0b2957fe7c9759815dc5b61de521a6e9a6 Mon Sep 17 00:00:00 2001 From: juampibermani <30930241+juampibermani@users.noreply.github.com> Date: Wed, 2 Jun 2021 17:03:03 -0300 Subject: [PATCH 2/2] Fix: don't display Intercom in Safe Apps (#2365) * Check if current screen is the app view * Get app url from utils hook * Hook rename and updated effect dependency --- src/components/CookiesBanner/index.tsx | 11 +++++++++-- src/logic/hooks/useSafeAppUrl.tsx | 22 ++++++++++++++++++++++ src/routes/safe/components/Apps/index.tsx | 14 ++++---------- 3 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 src/logic/hooks/useSafeAppUrl.tsx diff --git a/src/components/CookiesBanner/index.tsx b/src/components/CookiesBanner/index.tsx index 2bae1916..8b64d66e 100644 --- a/src/components/CookiesBanner/index.tsx +++ b/src/components/CookiesBanner/index.tsx @@ -9,6 +9,7 @@ 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' @@ -97,7 +98,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) @@ -106,6 +107,12 @@ const CookiesBanner = (): ReactElement => { const showBanner = useSelector(cookieBannerOpen) + useEffect(() => { + if (appUrl) { + setTimeout(closeIntercom, 50) + } + }, [appUrl]) + useEffect(() => { async function fetchCookiesFromStorage() { const cookiesState = await loadFromCookie(COOKIES_KEY) @@ -171,7 +178,7 @@ const CookiesBanner = (): ReactElement => { dispatch.current(openCookieBanner({ cookieBannerOpen: false })) } - if (showIntercom) { + if (showIntercom && !appUrl) { loadIntercom() } diff --git a/src/logic/hooks/useSafeAppUrl.tsx b/src/logic/hooks/useSafeAppUrl.tsx new file mode 100644 index 00000000..fa6b93f4 --- /dev/null +++ b/src/logic/hooks/useSafeAppUrl.tsx @@ -0,0 +1,22 @@ +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 5fa825c0..25b28588 100644 --- a/src/routes/safe/components/Apps/index.tsx +++ b/src/routes/safe/components/Apps/index.tsx @@ -1,20 +1,14 @@ import React from 'react' - -import { useLocation } from 'react-router-dom' +import { useSafeAppUrl } from 'src/logic/hooks/useSafeAppUrl' import AppFrame from './components/AppFrame' import AppsList from './components/AppsList' -const useQuery = () => { - return new URLSearchParams(useLocation().search) -} - const Apps = (): React.ReactElement => { - const query = useQuery() - const appUrl = query.get('appUrl') + const { url } = useSafeAppUrl() - if (appUrl) { - return + if (url) { + return } else { return }