From 0c41b3188a4f4ffc701b980d98e3e7560ee2bc7b Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 8 May 2024 03:10:03 +0100 Subject: [Session] Remove global agent (#3852) * Remove logs and outdated comments * Move side effect upwards * Pull refreshedAccount next to usage * Simplify account refresh logic * Extract setupPublicAgentState() * Collapse setStates into one * Ignore events from stale agents * Use agent from state * Remove clearCurrentAccount * Move state to a reducer * Remove global agent * Fix stale agent reference in create flow * Proceed to onboarding even if setting date fails --------- Co-authored-by: Eric Bailey --- src/state/session/util/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/state/session/util/index.ts') diff --git a/src/state/session/util/index.ts b/src/state/session/util/index.ts index e3e246f7b..8c98aceb0 100644 --- a/src/state/session/util/index.ts +++ b/src/state/session/util/index.ts @@ -1,11 +1,12 @@ import {BSKY_LABELER_DID, BskyAgent} from '@atproto/api' import {jwtDecode} from 'jwt-decode' -import {IS_TEST_USER} from '#/lib/constants' +import {IS_PROD_SERVICE, IS_TEST_USER} from '#/lib/constants' import {tryFetchGates} from '#/lib/statsig/statsig' import {hasProp} from '#/lib/type-guards' import {logger} from '#/logger' import * as persisted from '#/state/persisted' +import {DEFAULT_PROD_FEEDS} from '#/state/queries/preferences' import {readLabelers} from '../agent-config' import {SessionAccount, SessionApiContext} from '../types' @@ -132,6 +133,7 @@ export async function createAgentAndCreateAccount({ email, password, handle, + birthDate, inviteCode, verificationPhone, verificationCode, @@ -167,6 +169,13 @@ export async function createAgentAndCreateAccount({ }) } + // Not awaited so that we can still get into onboarding. + // This is OK because we won't let you toggle adult stuff until you set the date. + agent.setPersonalDetails({birthDate: birthDate.toISOString()}) + if (IS_PROD_SERVICE(service)) { + agent.setSavedFeeds(DEFAULT_PROD_FEEDS.saved, DEFAULT_PROD_FEEDS.pinned) + } + await configureModerationForAccount(agent, account) return { -- cgit 1.4.1