| 1 | import { loadPreferences, updatePreferences } from "../../persistence/imperative"; |
| 2 | |
| 3 | // Lives apart from connectOnboarding.ts so CloudAuthProvider (which imports |
| 4 | // the request signal) never pulls the persistence adapter into its |
| 5 | // module graph; that breaks CloudAuthProvider.test.ts suite loading. |
| 6 | |
| 7 | /** Whether the account chose "Don't show this again". */ |
| 8 | export async function isConnectOnboardingOptedOut(accountId: string): Promise<boolean> { |
| 9 | const preferences = await loadPreferences(); |
| 10 | return preferences.connectOnboardingOptOutAccounts?.includes(accountId) ?? false; |
| 11 | } |
| 12 | |
| 13 | /** Persists "Don't show this again" for the account. */ |
| 14 | export async function optOutOfConnectOnboarding(accountId: string): Promise<void> { |
| 15 | await updatePreferences((current) => { |
| 16 | const optedOut = current.connectOnboardingOptOutAccounts ?? []; |
| 17 | return optedOut.includes(accountId) |
| 18 | ? {} |
| 19 | : { connectOnboardingOptOutAccounts: [...optedOut, accountId] }; |
| 20 | }); |
| 21 | } |