Ensure userMetadata is cleared when logging out
This commit is contained in:
@@ -67,7 +67,7 @@ if (env.IS_WEB) {
|
||||
}
|
||||
|
||||
let userMetadata: UserMetadata | null = null
|
||||
export function updateUserMetadata(account: persisted.PersistedAccount | null) {
|
||||
export function setUserMetadata(account: persisted.PersistedAccount | null) {
|
||||
if (account === null) {
|
||||
userMetadata = null
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import {getAge} from '#/lib/strings/time'
|
||||
import {logger} from '#/logger'
|
||||
import {refresh as refreshGates} from '#/logger/growthbook'
|
||||
import {updateUserMetadata} from '#/logger/metadata'
|
||||
import {setUserMetadata} from '#/logger/metadata'
|
||||
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
|
||||
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
|
||||
import {
|
||||
@@ -64,7 +64,7 @@ export async function createAgentAndResume(
|
||||
if (storedAccount.pdsUrl) {
|
||||
agent.sessionManager.pdsUrl = new URL(storedAccount.pdsUrl)
|
||||
}
|
||||
updateUserMetadata(storedAccount)
|
||||
setUserMetadata(storedAccount)
|
||||
const gates = refreshGates({
|
||||
strategy: 'prefer-low-latency',
|
||||
})
|
||||
@@ -127,7 +127,7 @@ export async function createAgentAndLogin(
|
||||
})
|
||||
|
||||
const account = agentToSessionAccountOrThrow(agent)
|
||||
updateUserMetadata(account)
|
||||
setUserMetadata(account)
|
||||
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
||||
const moderation = configureModerationForAccount(agent, account)
|
||||
const aa = prefetchAgeAssuranceData({agent})
|
||||
@@ -176,7 +176,7 @@ export async function createAgentAndCreateAccount(
|
||||
verificationCode,
|
||||
})
|
||||
const account = agentToSessionAccountOrThrow(agent)
|
||||
updateUserMetadata(account)
|
||||
setUserMetadata(account)
|
||||
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
||||
const moderation = configureModerationForAccount(agent, account)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react'
|
||||
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
|
||||
|
||||
import {setUserMetadata} from '#/logger/metadata'
|
||||
import * as persisted from '#/state/persisted'
|
||||
import {useCloseAllActiveElements} from '#/state/util'
|
||||
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
||||
@@ -15,7 +16,6 @@ import {
|
||||
sessionAccountToSession,
|
||||
} from './agent'
|
||||
import {type Action, getInitialState, reducer, type State} from './reducer'
|
||||
|
||||
export {isSignupQueued} from './util'
|
||||
import {addSessionDebugLog} from './logging'
|
||||
export type {SessionAccount} from '#/state/session/types'
|
||||
@@ -111,6 +111,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
accountDid,
|
||||
sessionEvent,
|
||||
})
|
||||
if (!refreshedAccount) {
|
||||
setUserMetadata(null)
|
||||
}
|
||||
},
|
||||
[store],
|
||||
)
|
||||
@@ -170,8 +173,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
SessionApiContext['logoutCurrentAccount']
|
||||
>(
|
||||
logContext => {
|
||||
// TODO
|
||||
// const gates = refreshGates({account, strategy: 'prefer-fresh-gates'})
|
||||
addSessionDebugLog({type: 'method:start', method: 'logout'})
|
||||
cancelPendingTask()
|
||||
const prevState = store.getState()
|
||||
@@ -184,6 +185,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
{statsig: true},
|
||||
)
|
||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||
setUserMetadata(null)
|
||||
if (prevState.currentAgentState.did) {
|
||||
clearAgeAssuranceDataForDid({did: prevState.currentAgentState.did})
|
||||
}
|
||||
@@ -208,6 +210,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
{statsig: true},
|
||||
)
|
||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||
setUserMetadata(null)
|
||||
clearAgeAssuranceData()
|
||||
// reset onboarding flow on logout
|
||||
onboardingDispatch({type: 'skip'})
|
||||
|
||||
Reference in New Issue
Block a user