mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Ready for push feature
This commit is contained in:
35
src/utils/push/useNavigate.ts
Normal file
35
src/utils/push/useNavigate.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import apiInstance from '@api/instance'
|
||||
import { NavigationContainerRef } from '@react-navigation/native'
|
||||
|
||||
const pushUseNavigate = (
|
||||
navigationRef: React.RefObject<NavigationContainerRef>,
|
||||
id?: Mastodon.Notification['id']
|
||||
) => {
|
||||
navigationRef.current?.navigate('Screen-Tabs', {
|
||||
screen: 'Tab-Notifications',
|
||||
params: {
|
||||
screen: 'Tab-Notifications-Root'
|
||||
}
|
||||
})
|
||||
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
apiInstance<Mastodon.Notification>({
|
||||
method: 'get',
|
||||
url: `notifications/${id}`
|
||||
}).then(({ body }) => {
|
||||
if (body.status) {
|
||||
navigationRef.current?.navigate('Screen-Tabs', {
|
||||
screen: 'Tab-Notifications',
|
||||
params: {
|
||||
screen: 'Tab-Shared-Toot',
|
||||
params: { toot: body.status }
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default pushUseNavigate
|
Reference in New Issue
Block a user