Revert "Fix: don't display Intercom in Safe Apps (#2365)"

This reverts commit 07465a0b29.
This commit is contained in:
katspaugh 2021-06-07 09:21:33 +02:00
parent 5f3598aed5
commit c424c67d07
3 changed files with 13 additions and 36 deletions

View File

@ -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()
}

View File

@ -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<string | null>(null)
const { search } = useLocation()
useEffect(() => {
if (search !== url) {
const query = new URLSearchParams(search)
setUrl(query.get('appUrl'))
}
}, [search, url])
return {
url,
}
}

View File

@ -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 Apps = (): React.ReactElement => {
const { url } = useSafeAppUrl()
const useQuery = () => {
return new URLSearchParams(useLocation().search)
}
if (url) {
return <AppFrame appUrl={url} />
const Apps = (): React.ReactElement => {
const query = useQuery()
const appUrl = query.get('appUrl')
if (appUrl) {
return <AppFrame appUrl={appUrl} />
} else {
return <AppsList />
}