mirror of https://github.com/tooot-app/app
Fix Android browser package
This commit is contained in:
parent
d8bff02136
commit
9f76fa08a8
|
@ -1,5 +1,6 @@
|
|||
import Button from '@components/Button'
|
||||
import Icon from '@components/Icon'
|
||||
import browserPackage from '@helpers/browserPackage'
|
||||
import { useAppsQuery } from '@utils/queryHooks/apps'
|
||||
import { useInstanceQuery } from '@utils/queryHooks/instance'
|
||||
import { getInstances } from '@utils/slices/instancesSlice'
|
||||
|
@ -254,13 +255,19 @@ const ComponentInstance: React.FC<Props> = ({
|
|||
<CustomText
|
||||
accessible
|
||||
style={{ color: colors.blue }}
|
||||
onPress={() => WebBrowser.openBrowserAsync('https://tooot.app/privacy-policy')}
|
||||
onPress={async () =>
|
||||
WebBrowser.openBrowserAsync('https://tooot.app/privacy-policy', {
|
||||
browserPackage: await browserPackage()
|
||||
})
|
||||
}
|
||||
/>,
|
||||
<CustomText
|
||||
accessible
|
||||
style={{ color: colors.blue }}
|
||||
onPress={() =>
|
||||
WebBrowser.openBrowserAsync('https://tooot.app/terms-of-service')
|
||||
onPress={async () =>
|
||||
WebBrowser.openBrowserAsync('https://tooot.app/terms-of-service', {
|
||||
browserPackage: await browserPackage()
|
||||
})
|
||||
}
|
||||
/>
|
||||
]}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import browserPackage from '@helpers/browserPackage'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useAppDispatch } from '@root/store'
|
||||
import { InstanceLatest } from '@utils/migrations/instances/migration'
|
||||
|
@ -5,9 +6,7 @@ import { TabMeStackNavigationProp } from '@utils/navigation/navigators'
|
|||
import addInstance from '@utils/slices/instances/add'
|
||||
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
|
||||
import * as AuthSession from 'expo-auth-session'
|
||||
import * as WebBrowser from 'expo-web-browser'
|
||||
import React, { useEffect } from 'react'
|
||||
import { Platform } from 'react-native'
|
||||
import { useQueryClient } from 'react-query'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
|
@ -47,15 +46,7 @@ const InstanceAuth = React.memo(
|
|||
useEffect(() => {
|
||||
;(async () => {
|
||||
if (request?.clientId) {
|
||||
let browserPackage: string | undefined
|
||||
if (Platform.OS === 'android') {
|
||||
const tabsSupportingBrowsers = await WebBrowser.getCustomTabsSupportingBrowsersAsync()
|
||||
browserPackage =
|
||||
tabsSupportingBrowsers?.preferredBrowserPackage ||
|
||||
tabsSupportingBrowsers.browserPackages[0] ||
|
||||
tabsSupportingBrowsers.servicePackages[0]
|
||||
}
|
||||
await promptAsync({ browserPackage }).catch(e => console.log(e))
|
||||
await promptAsync({ browserPackage: await browserPackage() }).catch(e => console.log(e))
|
||||
}
|
||||
})()
|
||||
}, [request])
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import apiInstance from '@api/instance'
|
||||
import browserPackage from '@helpers/browserPackage'
|
||||
import navigationRef from '@helpers/navigationRef'
|
||||
import { matchAccount, matchStatus } from '@helpers/urlMatcher'
|
||||
import { store } from '@root/store'
|
||||
|
@ -91,7 +92,8 @@ const openLink = async (url: string, navigation?: any) => {
|
|||
case 'internal':
|
||||
await WebBrowser.openBrowserAsync(encodeURI(url), {
|
||||
dismissButtonStyle: 'close',
|
||||
enableBarCollapsing: true
|
||||
enableBarCollapsing: true,
|
||||
browserPackage: await browserPackage()
|
||||
})
|
||||
break
|
||||
case 'external':
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import * as WebBrowser from 'expo-web-browser'
|
||||
import { Platform } from 'react-native'
|
||||
|
||||
const browserPackage = async () => {
|
||||
let browserPackage: string | undefined
|
||||
if (Platform.OS === 'android') {
|
||||
const tabsSupportingBrowsers = await WebBrowser.getCustomTabsSupportingBrowsersAsync()
|
||||
browserPackage =
|
||||
tabsSupportingBrowsers?.preferredBrowserPackage ||
|
||||
tabsSupportingBrowsers.browserPackages[0] ||
|
||||
tabsSupportingBrowsers.servicePackages[0]
|
||||
}
|
||||
return browserPackage
|
||||
}
|
||||
|
||||
export default browserPackage
|
|
@ -2,6 +2,7 @@ import Button from '@components/Button'
|
|||
import Icon from '@components/Icon'
|
||||
import { MenuContainer, MenuRow } from '@components/Menu'
|
||||
import CustomText from '@components/Text'
|
||||
import browserPackage from '@helpers/browserPackage'
|
||||
import { useAppDispatch } from '@root/store'
|
||||
import { isDevelopment } from '@utils/checkEnvironment'
|
||||
import { getExpoToken } from '@utils/slices/appSlice'
|
||||
|
@ -153,7 +154,11 @@ const TabMePush: React.FC = () => {
|
|||
<MenuRow
|
||||
title={t('me.push.howitworks')}
|
||||
iconBack='ExternalLink'
|
||||
onPress={() => WebBrowser.openBrowserAsync('https://tooot.app/how-push-works')}
|
||||
onPress={async () =>
|
||||
WebBrowser.openBrowserAsync('https://tooot.app/how-push-works', {
|
||||
browserPackage: await browserPackage()
|
||||
})
|
||||
}
|
||||
/>
|
||||
</MenuContainer>
|
||||
<MenuContainer>{alerts}</MenuContainer>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { MenuContainer, MenuRow } from '@components/Menu'
|
||||
import browserPackage from '@helpers/browserPackage'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { getInstanceActive, getInstanceUrl } from '@utils/slices/instancesSlice'
|
||||
import * as WebBrowser from 'expo-web-browser'
|
||||
|
@ -25,11 +26,15 @@ const Settings: React.FC = () => {
|
|||
iconFront='Sliders'
|
||||
iconBack='ExternalLink'
|
||||
title={t('me.stacks.webSettings.name')}
|
||||
onPress={() =>
|
||||
onPress={async () =>
|
||||
WebBrowser.openAuthSessionAsync(
|
||||
`https://${url}/settings/preferences`,
|
||||
'tooot://tooot',
|
||||
{ dismissButtonStyle: 'done', readerMode: false }
|
||||
{
|
||||
browserPackage: await browserPackage(),
|
||||
dismissButtonStyle: 'done',
|
||||
readerMode: false
|
||||
}
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -14,6 +14,7 @@ import { isDevelopment, isRelease } from '@utils/checkEnvironment'
|
|||
import { Platform } from 'react-native'
|
||||
import Constants from 'expo-constants'
|
||||
import { getExpoToken } from '@utils/slices/appSlice'
|
||||
import browserPackage from '@helpers/browserPackage'
|
||||
|
||||
const SettingsTooot: React.FC = () => {
|
||||
const instanceActive = useSelector(getInstanceActive)
|
||||
|
@ -52,7 +53,7 @@ const SettingsTooot: React.FC = () => {
|
|||
title={t('me.settings.contact.heading')}
|
||||
content={<Icon name='Mail' size={StyleConstants.Font.Size.M} color={colors.secondary} />}
|
||||
iconBack='ChevronRight'
|
||||
onPress={() => {
|
||||
onPress={async () => {
|
||||
if (instanceActive !== -1) {
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'conversation',
|
||||
|
@ -71,7 +72,9 @@ const SettingsTooot: React.FC = () => {
|
|||
']'
|
||||
})
|
||||
} else {
|
||||
WebBrowser.openBrowserAsync('https://social.xmflsct.com/@tooot')
|
||||
WebBrowser.openBrowserAsync('https://social.xmflsct.com/@tooot', {
|
||||
browserPackage: await browserPackage()
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue