tooot/src/components/openLink.ts

18 lines
456 B
TypeScript

import { store } from '@root/store'
import { getSettingsBrowser } from '@utils/slices/settingsSlice'
import * as Linking from 'expo-linking'
import * as WebBrowser from 'expo-web-browser'
const openLink = async (url: string) => {
switch (getSettingsBrowser(store.getState())) {
case 'internal':
await WebBrowser.openBrowserAsync(url)
break
case 'external':
await Linking.openURL(url)
break
}
}
export default openLink