diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-15 17:17:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 17:17:50 -0800 |
commit | 6616b2bff098ff4a5e464c175edf2446dae0cc88 (patch) | |
tree | fb314b51dd3d17b488fa2971735aa7c19176493b /src/state/session/index.tsx | |
parent | f23e9978d839322aab7304d2b6f183722e3ad4c1 (diff) | |
download | voidsky-6616b2bff098ff4a5e464c175edf2446dae0cc88.tar.zst |
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
Diffstat (limited to 'src/state/session/index.tsx')
-rw-r--r-- | src/state/session/index.tsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index e01e841f6..b8422553c 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -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], ) |