mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
619 restructure local storage (#628)
* To MMKV migration working * POC migrated font size settings * Moved settings to mmkv * Fix typos * Migrated contexts slice * Migrated app slice * POC instance emoji update * Migrated drafts * Migrated simple instance properties * All migrated! * Re-structure files * Tolerant of undefined settings * Can properly logging in and out including empty state
This commit is contained in:
@ -1,14 +1,12 @@
|
||||
import queryClient from '@helpers/queryClient'
|
||||
import initQuery from '@utils/initQuery'
|
||||
import queryClient from '@utils/queryHooks'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { getInstances } from '@utils/slices/instancesSlice'
|
||||
import { generateAccountKey, setAccount, useGlobalStorage } from '@utils/storage/actions'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { useEffect } from 'react'
|
||||
import { useSelector } from 'react-redux'
|
||||
import pushUseNavigate from './useNavigate'
|
||||
|
||||
const pushUseRespond = () => {
|
||||
const instances = useSelector(getInstances, (prev, next) => prev.length === next.length)
|
||||
const [accounts] = useGlobalStorage.object('accounts')
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = Notifications.addNotificationResponseReceivedListener(
|
||||
@ -21,19 +19,19 @@ const pushUseRespond = () => {
|
||||
accountId: string
|
||||
}
|
||||
|
||||
const notificationIndex = instances.findIndex(
|
||||
instance =>
|
||||
instance.url === payloadData.instanceUrl &&
|
||||
instance.account.id === payloadData.accountId
|
||||
const currAccount = accounts?.find(
|
||||
account =>
|
||||
account ===
|
||||
generateAccountKey({ domain: payloadData.instanceUrl, id: payloadData.accountId })
|
||||
)
|
||||
if (notificationIndex !== -1) {
|
||||
initQuery({ instance: instances[notificationIndex] })
|
||||
if (currAccount) {
|
||||
setAccount(currAccount)
|
||||
}
|
||||
pushUseNavigate(payloadData.notification_id)
|
||||
}
|
||||
)
|
||||
return () => subscription.remove()
|
||||
}, [instances])
|
||||
}, [accounts])
|
||||
}
|
||||
|
||||
export default pushUseRespond
|
||||
|
Reference in New Issue
Block a user