Address lint warnings (#10188)

This commit is contained in:
DS Boyce
2026-04-08 15:54:43 -07:00
committed by GitHub
parent e4b4e48acb
commit d0d00ba9f8
15 changed files with 170 additions and 173 deletions
+10 -7
View File
@@ -8,7 +8,7 @@ import {
useState,
useSyncExternalStore,
} from 'react'
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
import {type AtpAgent, type AtpSessionEvent} from '@atproto/api'
import * as persisted from '#/state/persisted'
import {useCloseAllActiveElements} from '#/state/util'
@@ -47,7 +47,7 @@ const StateContext = createContext<SessionStateContext>({
})
StateContext.displayName = 'SessionStateContext'
const AgentContext = createContext<BskyAgent | null>(null)
const AgentContext = createContext<AtpAgent | null>(null)
AgentContext.displayName = 'SessionAgentContext'
const ApiContext = createContext<SessionApiContext>({
@@ -96,7 +96,7 @@ class SessionStore {
),
}
addSessionDebugLog({type: 'persisted:broadcast', data: persistedData})
persisted.write('session', persistedData)
void persisted.write('session', persistedData)
}
this.listeners.forEach(listener => listener())
}
@@ -105,12 +105,13 @@ class SessionStore {
export function Provider({children}: React.PropsWithChildren<{}>) {
const ax = useAnalyticsBase()
const cancelPendingTask = useOneTaskAtATime()
// eslint-disable-next-line react/hook-use-state
const [store] = useState(() => new SessionStore())
const state = useSyncExternalStore(store.subscribe, store.getState)
const onboardingDispatch = useOnboardingDispatch()
const onAgentSessionChange = useCallback(
(agent: BskyAgent, accountDid: string, sessionEvent: AtpSessionEvent) => {
(agent: AtpAgent, accountDid: string, sessionEvent: AtpSessionEvent) => {
const refreshedAccount = agentToSessionAccount(agent) // Mutable, so snapshot it right away.
if (sessionEvent === 'expired' || sessionEvent === 'create-failed') {
emitSessionDropped()
@@ -327,10 +328,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
* follower tabs. Follower tabs will therefore receive the fresh
* session. See APP-1960, or ask Eric.
*/
resumeSession(syncedAccount)
void resumeSession(syncedAccount)
} else {
const agent = state.currentAgentState.agent as BskyAgent
const agent = state.currentAgentState.agent as AtpAgent
const prevSession = agent.session
// eslint-disable-next-line react-compiler/react-compiler
agent.sessionManager.session = sessionAccountToSession(syncedAccount)
addSessionDebugLog({
type: 'agent:patch',
@@ -376,6 +378,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
)
// @ts-expect-error window type is not declared, debug only
// eslint-disable-next-line react-hooks/immutability
if (__DEV__ && IS_WEB) window.agent = state.currentAgentState.agent
const agent = state.currentAgentState.agent as BskyAppAgent
@@ -448,7 +451,7 @@ export function useRequireAuth() {
)
}
export function useAgent(): BskyAgent {
export function useAgent(): AtpAgent {
const agent = useContext(AgentContext)
if (!agent) {
throw Error('useAgent() must be below <SessionProvider>.')