Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
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
10 changes: 2 additions & 8 deletions src/routes/safe/components/Apps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import { useHistory } from 'react-router-dom'
import { useSelector } from 'react-redux'

import { useSafeAppUrl } from 'src/logic/hooks/useSafeAppUrl'
import { generateSafeRoute, SAFE_ROUTES } from 'src/routes/routes'
import { getCurrentShortChainName } from 'src/config'
import { currentSafe } from 'src/logic/safe/store/selectors'
import AppFrame from 'src/routes/safe/components/Apps/components/AppFrame'
import AppsList from 'src/routes/safe/components/Apps/components/AppsList'
import LegalDisclaimer from 'src/routes/safe/components/Apps/components/LegalDisclaimer'
import { useLegalConsent } from 'src/routes/safe/components/Apps/hooks/useLegalConsent'

const Apps = (): React.ReactElement => {
const history = useHistory()
const { address: safeAddress } = useSelector(currentSafe)
const { getAppUrl } = useSafeAppUrl()
const url = getAppUrl()
const { consentReceived, onConsentReceipt } = useLegalConsent()

const redirectToBalance = () =>
history.push(generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, { shortName: getCurrentShortChainName(), safeAddress }))
const goBack = () => history.goBack()

if (url) {
if (!consentReceived) {
return <LegalDisclaimer onCancel={redirectToBalance} onConfirm={onConsentReceipt} />
return <LegalDisclaimer onCancel={goBack} onConfirm={onConsentReceipt} />
}

return <AppFrame appUrl={url} />
Expand Down