mirror of
https://github.com/tooot-app/app
synced 2025-02-06 21:33:37 +01:00
parent
922d7c7917
commit
4b8885ef2c
@ -7,6 +7,7 @@ import { useEffect } from 'react'
|
||||
import pushUseNavigate from './useNavigate'
|
||||
|
||||
const pushUseReceive = () => {
|
||||
const [accountActive] = useGlobalStorage.string('account.active')
|
||||
const [accounts] = useGlobalStorage.object('accounts')
|
||||
|
||||
useEffect(() => {
|
||||
@ -19,25 +20,25 @@ const pushUseReceive = () => {
|
||||
accountId: string
|
||||
}
|
||||
|
||||
const currAccount = accounts?.find(
|
||||
account =>
|
||||
account ===
|
||||
generateAccountKey({ domain: payloadData.instanceUrl, id: payloadData.accountId })
|
||||
)
|
||||
const incomingAccount = generateAccountKey({
|
||||
domain: payloadData.instanceUrl,
|
||||
id: payloadData.accountId
|
||||
})
|
||||
const foundAccount = accounts?.find(account => account === incomingAccount)
|
||||
displayMessage({
|
||||
duration: 'long',
|
||||
message: notification.request.content.title!,
|
||||
description: notification.request.content.body!,
|
||||
onPress: () => {
|
||||
if (currAccount) {
|
||||
setAccount(currAccount)
|
||||
onPress: async () => {
|
||||
if (foundAccount && foundAccount !== accountActive) {
|
||||
await setAccount(foundAccount)
|
||||
}
|
||||
pushUseNavigate(payloadData.notification_id)
|
||||
}
|
||||
})
|
||||
})
|
||||
return () => subscription.remove()
|
||||
}, [accounts])
|
||||
}, [accountActive, accounts])
|
||||
}
|
||||
|
||||
export default pushUseReceive
|
||||
|
@ -6,11 +6,12 @@ import { useEffect } from 'react'
|
||||
import pushUseNavigate from './useNavigate'
|
||||
|
||||
const pushUseRespond = () => {
|
||||
const [accountActive] = useGlobalStorage.string('account.active')
|
||||
const [accounts] = useGlobalStorage.object('accounts')
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = Notifications.addNotificationResponseReceivedListener(
|
||||
({ notification }) => {
|
||||
async ({ notification }) => {
|
||||
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Notifications' }]
|
||||
queryClient.invalidateQueries(queryKey)
|
||||
const payloadData = notification.request.content.data as {
|
||||
@ -19,19 +20,19 @@ const pushUseRespond = () => {
|
||||
accountId: string
|
||||
}
|
||||
|
||||
const currAccount = accounts?.find(
|
||||
account =>
|
||||
account ===
|
||||
generateAccountKey({ domain: payloadData.instanceUrl, id: payloadData.accountId })
|
||||
)
|
||||
if (currAccount) {
|
||||
setAccount(currAccount)
|
||||
const incomingAccount = generateAccountKey({
|
||||
domain: payloadData.instanceUrl,
|
||||
id: payloadData.accountId
|
||||
})
|
||||
const foundAccount = accounts?.find(account => account === incomingAccount)
|
||||
if (foundAccount && foundAccount !== accountActive) {
|
||||
await setAccount(foundAccount)
|
||||
}
|
||||
pushUseNavigate(payloadData.notification_id)
|
||||
}
|
||||
)
|
||||
return () => subscription.remove()
|
||||
}, [accounts])
|
||||
}, [accountActive, accounts])
|
||||
}
|
||||
|
||||
export default pushUseRespond
|
||||
|
Loading…
x
Reference in New Issue
Block a user