From 7ff176db48a6c93ca9603ac337eab5f73adca72c Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 18 Jul 2025 19:11:32 -0700 Subject: [PATCH] fix notification reloading --- src/state/queries/notifications/unread.tsx | 2 ++ src/state/session/oauth-agent.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/state/queries/notifications/unread.tsx b/src/state/queries/notifications/unread.tsx index da8d681261..f4df77a8ce 100644 --- a/src/state/queries/notifications/unread.tsx +++ b/src/state/queries/notifications/unread.tsx @@ -127,7 +127,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) { isPoll, }: {invalidate?: boolean; isPoll?: boolean} = {}) { try { + // TODO: do we actually need this check? why? if (!agent.session) return + if (AppState.currentState !== 'active') { return } diff --git a/src/state/session/oauth-agent.ts b/src/state/session/oauth-agent.ts index f972a4f7f1..cda2387591 100644 --- a/src/state/session/oauth-agent.ts +++ b/src/state/session/oauth-agent.ts @@ -1,10 +1,11 @@ -import {Agent} from '@atproto/api' +import {Agent, type AtpSessionData} from '@atproto/api' import {type OutputSchema} from '@atproto/api/dist/client/types/com/atproto/server/getSession' import {type OAuthSession} from '@atproto/oauth-client-browser' import {BSKY_SERVICE} from '#/lib/constants' import {tryFetchGates} from '#/lib/statsig/statsig' import {logger} from '#/logger' +import {sessionAccountToSession} from './agent' import {configureModerationForAccount} from './moderation' import {BSKY_OAUTH_CLIENT} from './oauth-web-client' import {type SessionAccount} from './types' @@ -59,13 +60,16 @@ export async function oauthAgentAndSessionToSessionAccount( } export class OauthBskyAppAgent extends Agent { - #session: OAuthSession + // this is a field available in AtpAgent, so we'll add it here + session?: AtpSessionData + + #oauthSession: OAuthSession #account?: SessionAccount constructor(session: OAuthSession) { super(session) - this.#session = session + this.#oauthSession = session } async prepare(gates: Promise, moderation: Promise) { @@ -73,9 +77,10 @@ export class OauthBskyAppAgent extends Agent { // OAuthSession itself, unlike the old agent const account = await oauthAgentAndSessionToSessionAccountOrThrow( this, - this.#session, + this.#oauthSession, ) this.#account = account + this.session = sessionAccountToSession(account) await Promise.all([gates, moderation])