2022-12-28 23:41:36 +01:00
|
|
|
import apiInstance from '@utils/api/instance'
|
|
|
|
import navigationRef from '@utils/navigation/navigationRef'
|
2021-03-04 01:03:53 +01:00
|
|
|
|
2021-08-29 15:25:38 +02:00
|
|
|
const pushUseNavigate = (id?: Mastodon.Notification['id']) => {
|
|
|
|
navigationRef.navigate('Screen-Tabs', {
|
2021-03-04 01:03:53 +01:00
|
|
|
screen: 'Tab-Notifications',
|
2023-01-04 22:39:29 +01:00
|
|
|
params: { screen: 'Tab-Notifications-Root', params: {} }
|
2021-03-04 01:03:53 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
if (!id) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
apiInstance<Mastodon.Notification>({
|
|
|
|
method: 'get',
|
|
|
|
url: `notifications/${id}`
|
|
|
|
}).then(({ body }) => {
|
|
|
|
if (body.status) {
|
2021-08-29 15:25:38 +02:00
|
|
|
navigationRef.navigate('Screen-Tabs', {
|
2021-03-04 01:03:53 +01:00
|
|
|
screen: 'Tab-Notifications',
|
|
|
|
params: {
|
|
|
|
screen: 'Tab-Shared-Toot',
|
|
|
|
params: { toot: body.status }
|
|
|
|
}
|
|
|
|
})
|
2023-04-17 22:42:56 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (body.type === 'follow' || body.type === 'follow_request') {
|
|
|
|
if (body.account) {
|
|
|
|
navigationRef.navigate('Screen-Tabs', {
|
|
|
|
screen: 'Tab-Notifications',
|
|
|
|
params: {
|
|
|
|
screen: 'Tab-Shared-Account',
|
|
|
|
params: { account: body.account }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
2021-03-04 01:03:53 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default pushUseNavigate
|