mirror of
https://github.com/tooot-app/app
synced 2025-03-11 00:50:14 +01:00
Fix #717
This commit is contained in:
parent
0db7f0c40a
commit
173d4248d8
@ -1,2 +1 @@
|
|||||||
Enjoy toooting! This version includes following improvements and fixes:
|
Enjoy toooting! This version includes following improvements and fixes:
|
||||||
- Added Belarusian language
|
|
@ -1,2 +1 @@
|
|||||||
toooting愉快!此版本包括以下改进和修复:
|
toooting愉快!此版本包括以下改进和修复:
|
||||||
- 新增白俄罗斯语
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tooot",
|
"name": "tooot",
|
||||||
"version": "4.9.1",
|
"version": "4.9.2",
|
||||||
"description": "tooot for Mastodon",
|
"description": "tooot for Mastodon",
|
||||||
"author": "xmflsct <me@xmflsct.com>",
|
"author": "xmflsct <me@xmflsct.com>",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
|
@ -7,6 +7,7 @@ import ScreenAnnouncements from '@screens/Announcements'
|
|||||||
import ScreenCompose from '@screens/Compose'
|
import ScreenCompose from '@screens/Compose'
|
||||||
import ScreenImagesViewer from '@screens/ImageViewer'
|
import ScreenImagesViewer from '@screens/ImageViewer'
|
||||||
import ScreenTabs from '@screens/Tabs'
|
import ScreenTabs from '@screens/Tabs'
|
||||||
|
import { useLinking } from '@utils/linking'
|
||||||
import navigationRef from '@utils/navigation/navigationRef'
|
import navigationRef from '@utils/navigation/navigationRef'
|
||||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||||
import pushUseConnect from '@utils/push/useConnect'
|
import pushUseConnect from '@utils/push/useConnect'
|
||||||
@ -78,32 +79,8 @@ const Screens: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deep linking for compose
|
// Deep linking
|
||||||
const [deeplinked, setDeeplinked] = useState(false)
|
useLinking()
|
||||||
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])
|
|
||||||
|
|
||||||
// Share Extension
|
// Share Extension
|
||||||
const handleShare = (
|
const handleShare = (
|
||||||
|
41
src/utils/linking/index.ts
Normal file
41
src/utils/linking/index.ts
Normal 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()
|
||||||
|
}, [])
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user