about summary refs log tree commit diff
path: root/src/state/session/agent.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/session/agent.ts')
-rw-r--r--src/state/session/agent.ts34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts
index 024f6e7d1..9633dc0e3 100644
--- a/src/state/session/agent.ts
+++ b/src/state/session/agent.ts
@@ -1,10 +1,15 @@
 import {AtpSessionData, AtpSessionEvent, BskyAgent} from '@atproto/api'
+import {TID} from '@atproto/common-web'
 
 import {networkRetry} from '#/lib/async/retry'
-import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
-import {IS_PROD_SERVICE} from '#/lib/constants'
+import {
+  DISCOVER_SAVED_FEED,
+  IS_PROD_SERVICE,
+  PUBLIC_BSKY_SERVICE,
+  TIMELINE_SAVED_FEED,
+} from '#/lib/constants'
 import {tryFetchGates} from '#/lib/statsig/statsig'
-import {DEFAULT_PROD_FEEDS} from '../queries/preferences'
+import {logger} from '#/logger'
 import {
   configureModerationForAccount,
   configureModerationForGuest,
@@ -134,9 +139,28 @@ 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)
+    try {
+      networkRetry(1, async () => {
+        await agent.setPersonalDetails({birthDate: birthDate.toISOString()})
+        await agent.overwriteSavedFeeds([
+          {
+            ...DISCOVER_SAVED_FEED,
+            id: TID.nextStr(),
+          },
+          {
+            ...TIMELINE_SAVED_FEED,
+            id: TID.nextStr(),
+          },
+        ])
+      })
+    } catch (e: any) {
+      logger.error(e, {
+        context: `session: createAgentAndCreateAccount failed to save personal details and feeds`,
+      })
+    }
+  } else {
+    agent.setPersonalDetails({birthDate: birthDate.toISOString()})
   }
 
   return prepareAgent(agent, gates, moderation, onSessionChange)