fix: update PolicyUpdateModal to open documents in system browser
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
import { Browser } from '@capacitor/browser'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import { ChevronRight, Gavel, PrivacyTip } from '@mui/icons-material'
|
||||
import { Button, Stack } from '@mui/joy'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import ModalActions from '../../components/common/ModalActions.jsx'
|
||||
import { useResponsiveModal } from '../../hooks/useResponsiveModal.js'
|
||||
|
||||
const POLICY_BASE_URL = 'https://app.donetick.com'
|
||||
|
||||
// Native webviews swallow target="_blank"; route through the system browser.
|
||||
const openUrl = async url => {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
await Browser.open({ url })
|
||||
} else {
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One-time notice that the Privacy Policy and Terms changed. The frame is
|
||||
* generic and always points at the documents, so a future revision only needs
|
||||
@@ -14,7 +26,6 @@ import { useResponsiveModal } from '../../hooks/useResponsiveModal.js'
|
||||
const PolicyUpdateModal = ({ onAcknowledge, onClose, open }) => {
|
||||
const { t } = useTranslation()
|
||||
const { ResponsiveModal } = useResponsiveModal()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const handleClose = () => {
|
||||
onAcknowledge?.()
|
||||
@@ -23,7 +34,7 @@ const PolicyUpdateModal = ({ onAcknowledge, onClose, open }) => {
|
||||
|
||||
const openDocument = path => {
|
||||
handleClose()
|
||||
navigate(path)
|
||||
openUrl(`${POLICY_BASE_URL}${path}`)
|
||||
}
|
||||
|
||||
const documentButtonSx = {
|
||||
|
||||
Reference in New Issue
Block a user