Shell behaviors update (react-query refactor) (#1915)
* Move tick-every-minute into a hook/context * Move soft-reset event out of the shell model * Update soft-reset listener on new search page * Implement session-loaded and session-dropped events * Update analytics and push-notifications to use new session system
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React from 'react'
|
||||
import {DeviceEventEmitter} from 'react-native'
|
||||
import {BskyAgent, AtpPersistSessionHandler} from '@atproto/api'
|
||||
|
||||
import {networkRetry} from '#/lib/async/retry'
|
||||
@@ -7,6 +6,7 @@ import {logger} from '#/logger'
|
||||
import * as persisted from '#/state/persisted'
|
||||
import {PUBLIC_BSKY_AGENT} from '#/state/queries'
|
||||
import {IS_PROD} from '#/lib/constants'
|
||||
import {emitSessionLoaded, emitSessionDropped} from '../events'
|
||||
|
||||
export type SessionAccount = persisted.PersistedAccount
|
||||
|
||||
@@ -98,7 +98,9 @@ function createPersistSessionHandler(
|
||||
logger.DebugContext.session,
|
||||
)
|
||||
|
||||
if (expired) DeviceEventEmitter.emit('session-dropped')
|
||||
if (expired) {
|
||||
emitSessionDropped()
|
||||
}
|
||||
|
||||
persistSessionCallback({
|
||||
expired,
|
||||
@@ -180,6 +182,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
|
||||
setState(s => ({...s, agent}))
|
||||
upsertAccount(account)
|
||||
emitSessionLoaded(account, agent)
|
||||
|
||||
logger.debug(
|
||||
`session: created account`,
|
||||
@@ -230,6 +233,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
|
||||
setState(s => ({...s, agent}))
|
||||
upsertAccount(account)
|
||||
emitSessionLoaded(account, agent)
|
||||
|
||||
logger.debug(
|
||||
`session: logged in`,
|
||||
@@ -291,6 +295,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
|
||||
setState(s => ({...s, agent}))
|
||||
upsertAccount(account)
|
||||
emitSessionLoaded(account, agent)
|
||||
},
|
||||
[upsertAccount],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user