fix notification reloading
This commit is contained in:
@@ -127,7 +127,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
isPoll,
|
isPoll,
|
||||||
}: {invalidate?: boolean; isPoll?: boolean} = {}) {
|
}: {invalidate?: boolean; isPoll?: boolean} = {}) {
|
||||||
try {
|
try {
|
||||||
|
// TODO: do we actually need this check? why?
|
||||||
if (!agent.session) return
|
if (!agent.session) return
|
||||||
|
|
||||||
if (AppState.currentState !== 'active') {
|
if (AppState.currentState !== 'active') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 OutputSchema} from '@atproto/api/dist/client/types/com/atproto/server/getSession'
|
||||||
import {type OAuthSession} from '@atproto/oauth-client-browser'
|
import {type OAuthSession} from '@atproto/oauth-client-browser'
|
||||||
|
|
||||||
import {BSKY_SERVICE} from '#/lib/constants'
|
import {BSKY_SERVICE} from '#/lib/constants'
|
||||||
import {tryFetchGates} from '#/lib/statsig/statsig'
|
import {tryFetchGates} from '#/lib/statsig/statsig'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {sessionAccountToSession} from './agent'
|
||||||
import {configureModerationForAccount} from './moderation'
|
import {configureModerationForAccount} from './moderation'
|
||||||
import {BSKY_OAUTH_CLIENT} from './oauth-web-client'
|
import {BSKY_OAUTH_CLIENT} from './oauth-web-client'
|
||||||
import {type SessionAccount} from './types'
|
import {type SessionAccount} from './types'
|
||||||
@@ -59,13 +60,16 @@ export async function oauthAgentAndSessionToSessionAccount(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class OauthBskyAppAgent extends Agent {
|
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
|
#account?: SessionAccount
|
||||||
|
|
||||||
constructor(session: OAuthSession) {
|
constructor(session: OAuthSession) {
|
||||||
super(session)
|
super(session)
|
||||||
|
|
||||||
this.#session = session
|
this.#oauthSession = session
|
||||||
}
|
}
|
||||||
|
|
||||||
async prepare(gates: Promise<void>, moderation: Promise<void>) {
|
async prepare(gates: Promise<void>, moderation: Promise<void>) {
|
||||||
@@ -73,9 +77,10 @@ export class OauthBskyAppAgent extends Agent {
|
|||||||
// OAuthSession itself, unlike the old agent
|
// OAuthSession itself, unlike the old agent
|
||||||
const account = await oauthAgentAndSessionToSessionAccountOrThrow(
|
const account = await oauthAgentAndSessionToSessionAccountOrThrow(
|
||||||
this,
|
this,
|
||||||
this.#session,
|
this.#oauthSession,
|
||||||
)
|
)
|
||||||
this.#account = account
|
this.#account = account
|
||||||
|
this.session = sessionAccountToSession(account)
|
||||||
|
|
||||||
await Promise.all([gates, moderation])
|
await Promise.all([gates, moderation])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user