This commit is contained in:
xmflsct 2023-03-12 18:09:33 +01:00
parent 0db7f0c40a
commit 173d4248d8
5 changed files with 45 additions and 29 deletions

View File

@ -1,2 +1 @@
Enjoy toooting! This version includes following improvements and fixes:
- Added Belarusian language

View File

@ -1,2 +1 @@
toooting愉快此版本包括以下改进和修复
- 新增白俄罗斯语

View File

@ -1,6 +1,6 @@
{
"name": "tooot",
"version": "4.9.1",
"version": "4.9.2",
"description": "tooot for Mastodon",
"author": "xmflsct <me@xmflsct.com>",
"license": "GPL-3.0-or-later",

View File

@ -7,6 +7,7 @@ import ScreenAnnouncements from '@screens/Announcements'
import ScreenCompose from '@screens/Compose'
import ScreenImagesViewer from '@screens/ImageViewer'
import ScreenTabs from '@screens/Tabs'
import { useLinking } from '@utils/linking'
import navigationRef from '@utils/navigation/navigationRef'
import { RootStackParamList } from '@utils/navigation/navigators'
import pushUseConnect from '@utils/push/useConnect'
@ -78,32 +79,8 @@ const Screens: React.FC = () => {
}
}
// Deep linking for compose
const [deeplinked, setDeeplinked] = useState(false)
useEffect(() => {
const getUrlAsync = async () => {
setDeeplinked(true)
const initialUrl = await Linking.parseInitialURLAsync()
if (initialUrl.path) {
const paths = initialUrl.path.split('/')
if (paths.length) {
if (accountActive && !accounts?.includes(accountActive)) {
setAccount(accountActive)
}
}
}
if (initialUrl.hostname === 'compose') {
navigationRef.navigate('Screen-Compose')
}
}
if (!deeplinked) {
getUrlAsync()
}
}, [accounts, accountActive, deeplinked])
// Deep linking
useLinking()
// Share Extension
const handleShare = (

View File

@ -0,0 +1,41 @@
import openLink from '@components/openLink'
import navigationRef from '@utils/navigation/navigationRef'
import { getReadableAccounts, setAccount } from '@utils/storage/actions'
import * as Linking from 'expo-linking'
import { useEffect } from 'react'
// /compose OR /compose/@username@example.com
export const useLinking = () => {
const parseLink = async (link: string) => {
const parsed = Linking.parse(link)
switch (parsed.scheme) {
case 'tooot':
if (parsed.hostname === 'compose') {
if (parsed.path?.length) {
const accounts = getReadableAccounts()
const foundNotActiveAccount = accounts.find(
account => account.acct === parsed.path && !account.active
)
if (foundNotActiveAccount) {
await setAccount(foundNotActiveAccount.key)
}
}
navigationRef.navigate('Screen-Compose')
}
break
case 'https':
case 'http':
await openLink(link)
break
}
}
useEffect(() => {
Linking.getInitialURL().then(parseLink)
const listener = Linking.addEventListener('url', ({ url }) => parseLink(url))
return () => listener.remove()
}, [])
}