diff options
-rw-r--r-- | src/App.native.tsx | 4 | ||||
-rw-r--r-- | src/App.web.tsx | 4 | ||||
-rw-r--r-- | src/lib/constants.ts | 1 | ||||
-rw-r--r-- | src/state/queries/index.ts | 4 | ||||
-rw-r--r-- | src/state/session/util/readLastActiveAccount.ts | 6 |
5 files changed, 14 insertions, 5 deletions
diff --git a/src/App.native.tsx b/src/App.native.tsx index ede587c89..cf96781b7 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -16,8 +16,8 @@ import {useQueryClient} from '@tanstack/react-query' import {Provider as StatsigProvider} from '#/lib/statsig/statsig' import {init as initPersistedState} from '#/state/persisted' -import * as persisted from '#/state/persisted' import {Provider as LabelDefsProvider} from '#/state/preferences/label-defs' +import {readLastActiveAccount} from '#/state/session/util/readLastActiveAccount' import {useIntentHandler} from 'lib/hooks/useIntentHandler' import {useNotificationsListener} from 'lib/notifications/notifications' import {QueryProvider} from 'lib/react-query' @@ -64,7 +64,7 @@ function InnerApp() { Toast.show(_(msg`Sorry! Your session expired. Please log in again.`)) }) - const account = persisted.get('session').currentAccount + const account = readLastActiveAccount() resumeSession(account) }, [resumeSession, _]) diff --git a/src/App.web.tsx b/src/App.web.tsx index ccf7ecb49..639fbfafc 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -7,8 +7,8 @@ import {SafeAreaProvider} from 'react-native-safe-area-context' import {Provider as StatsigProvider} from '#/lib/statsig/statsig' import {init as initPersistedState} from '#/state/persisted' -import * as persisted from '#/state/persisted' import {Provider as LabelDefsProvider} from '#/state/preferences/label-defs' +import {readLastActiveAccount} from '#/state/session/util/readLastActiveAccount' import {useIntentHandler} from 'lib/hooks/useIntentHandler' import {QueryProvider} from 'lib/react-query' import {ThemeProvider} from 'lib/ThemeContext' @@ -42,7 +42,7 @@ function InnerApp() { // init useEffect(() => { - const account = persisted.get('session').currentAccount + const account = readLastActiveAccount() resumeSession(account) }, [resumeSession]) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index bbfdbe27f..3f8cf9472 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -4,6 +4,7 @@ export const LOCAL_DEV_SERVICE = Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583' export const STAGING_SERVICE = 'https://staging.bsky.dev' export const BSKY_SERVICE = 'https://bsky.social' +export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app' export const DEFAULT_SERVICE = BSKY_SERVICE const HELP_DESK_LANG = 'en-us' export const HELP_DESK_URL = `https://blueskyweb.zendesk.com/hc/${HELP_DESK_LANG}` diff --git a/src/state/queries/index.ts b/src/state/queries/index.ts index e7c5f577b..e30528ca1 100644 --- a/src/state/queries/index.ts +++ b/src/state/queries/index.ts @@ -1,7 +1,9 @@ import {BskyAgent} from '@atproto/api' +import {PUBLIC_BSKY_SERVICE} from '#/lib/constants' + export const PUBLIC_BSKY_AGENT = new BskyAgent({ - service: 'https://public.api.bsky.app', + service: PUBLIC_BSKY_SERVICE, }) export const STALE = { diff --git a/src/state/session/util/readLastActiveAccount.ts b/src/state/session/util/readLastActiveAccount.ts new file mode 100644 index 000000000..e0768b8a8 --- /dev/null +++ b/src/state/session/util/readLastActiveAccount.ts @@ -0,0 +1,6 @@ +import * as persisted from '#/state/persisted' + +export function readLastActiveAccount() { + const {currentAccount, accounts} = persisted.get('session') + return accounts.find(a => a.did === currentAccount?.did) +} |