diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/app-info.ts | 16 | ||||
-rw-r--r-- | src/lib/app-info.web.ts | 15 | ||||
-rw-r--r-- | src/lib/hooks/useAccountSwitcher.ts | 29 | ||||
-rw-r--r-- | src/lib/hooks/useNavigationTabState.ts | 3 | ||||
-rw-r--r-- | src/lib/hooks/useNavigationTabState.web.ts | 2 | ||||
-rw-r--r-- | src/lib/media/picker.tsx | 3 | ||||
-rw-r--r-- | src/lib/media/picker.web.tsx | 7 | ||||
-rw-r--r-- | src/lib/routes/types.ts | 6 | ||||
-rw-r--r-- | src/lib/statsig/gates.ts | 3 | ||||
-rw-r--r-- | src/lib/strings/helpers.ts | 10 |
10 files changed, 60 insertions, 34 deletions
diff --git a/src/lib/app-info.ts b/src/lib/app-info.ts index af265bfcb..00b0d7eca 100644 --- a/src/lib/app-info.ts +++ b/src/lib/app-info.ts @@ -4,7 +4,17 @@ export const BUILD_ENV = process.env.EXPO_PUBLIC_ENV export const IS_DEV = process.env.EXPO_PUBLIC_ENV === 'development' export const IS_TESTFLIGHT = process.env.EXPO_PUBLIC_ENV === 'testflight' -const UPDATES_CHANNEL = IS_TESTFLIGHT ? 'testflight' : 'production' -export const appVersion = `${nativeApplicationVersion} (${nativeBuildVersion}, ${ - IS_DEV ? 'development' : UPDATES_CHANNEL +// This is the commit hash that the current bundle was made from. The user can see the commit hash in the app's settings +// along with the other version info. Useful for debugging/reporting. +export const BUNDLE_IDENTIFIER = + process.env.EXPO_PUBLIC_BUNDLE_IDENTIFIER ?? 'dev' + +// This will always be in the format of YYMMDD, so that it always increases for each build. This should only be used +// for Statsig reporting and shouldn't be used to identify a specific bundle. +export const BUNDLE_DATE = + IS_TESTFLIGHT || IS_DEV ? 0 : Number(process.env.EXPO_PUBLIC_BUNDLE_DATE) + +export const appVersion = `${nativeApplicationVersion}.${nativeBuildVersion}` +export const bundleInfo = `${BUNDLE_IDENTIFIER} (${ + IS_DEV ? 'dev' : IS_TESTFLIGHT ? 'tf' : 'prod' })` diff --git a/src/lib/app-info.web.ts b/src/lib/app-info.web.ts index 5739b8783..fe2bc5fff 100644 --- a/src/lib/app-info.web.ts +++ b/src/lib/app-info.web.ts @@ -1,2 +1,17 @@ import {version} from '../../package.json' + +export const IS_DEV = process.env.EXPO_PUBLIC_ENV === 'development' + +// This is the commit hash that the current bundle was made from. The user can see the commit hash in the app's settings +// along with the other version info. Useful for debugging/reporting. +export const BUNDLE_IDENTIFIER = + process.env.EXPO_PUBLIC_BUNDLE_IDENTIFIER ?? 'dev' + +// This will always be in the format of YYMMDD, so that it always increases for each build. This should only be used +// for Statsig reporting and shouldn't be used to identify a specific bundle. +export const BUNDLE_DATE = IS_DEV + ? 0 + : Number(process.env.EXPO_PUBLIC_BUNDLE_DATE) + export const appVersion = version +export const bundleInfo = `${BUNDLE_IDENTIFIER} (${IS_DEV ? 'dev' : 'prod'})` diff --git a/src/lib/hooks/useAccountSwitcher.ts b/src/lib/hooks/useAccountSwitcher.ts index 6d2f7b36b..ad529f912 100644 --- a/src/lib/hooks/useAccountSwitcher.ts +++ b/src/lib/hooks/useAccountSwitcher.ts @@ -1,4 +1,4 @@ -import {useCallback} from 'react' +import {useCallback, useState} from 'react' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -8,12 +8,14 @@ import {isWeb} from '#/platform/detection' import {SessionAccount, useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import * as Toast from '#/view/com/util/Toast' +import {logEvent} from '../statsig/statsig' import {LogEvents} from '../statsig/statsig' export function useAccountSwitcher() { + const [pendingDid, setPendingDid] = useState<string | null>(null) const {_} = useLingui() const {track} = useAnalytics() - const {selectAccount, clearCurrentAccount} = useSessionApi() + const {initSession} = useSessionApi() const {requestSwitchToAccount} = useLoggedOutViewControls() const onPressSwitchAccount = useCallback( @@ -22,8 +24,12 @@ export function useAccountSwitcher() { logContext: LogEvents['account:loggedIn']['logContext'], ) => { track('Settings:SwitchAccountButtonClicked') - + if (pendingDid) { + // The session API isn't resilient to race conditions so let's just ignore this. + return + } try { + setPendingDid(account.did) if (account.accessJwt) { if (isWeb) { // We're switching accounts, which remounts the entire app. @@ -33,10 +39,9 @@ export function useAccountSwitcher() { // So we change the URL ourselves. The navigator will pick it up on remount. history.pushState(null, '', '/') } - await selectAccount(account, logContext) - setTimeout(() => { - Toast.show(_(msg`Signed in as @${account.handle}`)) - }, 100) + await initSession(account) + logEvent('account:loggedIn', {logContext, withPassword: false}) + Toast.show(_(msg`Signed in as @${account.handle}`)) } else { requestSwitchToAccount({requestedAccount: account.did}) Toast.show( @@ -48,14 +53,12 @@ export function useAccountSwitcher() { logger.error(`switch account: selectAccount failed`, { message: e.message, }) - clearCurrentAccount() // back user out to login - setTimeout(() => { - Toast.show(_(msg`Sorry! We need you to enter your password.`)) - }, 100) + } finally { + setPendingDid(null) } }, - [_, track, clearCurrentAccount, selectAccount, requestSwitchToAccount], + [_, track, initSession, requestSwitchToAccount, pendingDid], ) - return {onPressSwitchAccount} + return {onPressSwitchAccount, pendingDid} } diff --git a/src/lib/hooks/useNavigationTabState.ts b/src/lib/hooks/useNavigationTabState.ts index 7fc0c65be..c70653e3a 100644 --- a/src/lib/hooks/useNavigationTabState.ts +++ b/src/lib/hooks/useNavigationTabState.ts @@ -11,8 +11,9 @@ export function useNavigationTabState() { isAtNotifications: getTabState(state, 'Notifications') !== TabState.Outside, isAtMyProfile: getTabState(state, 'MyProfile') !== TabState.Outside, - isAtMessages: getTabState(state, 'MessagesList') !== TabState.Outside, + isAtMessages: getTabState(state, 'Messages') !== TabState.Outside, } + if ( !res.isAtHome && !res.isAtSearch && diff --git a/src/lib/hooks/useNavigationTabState.web.ts b/src/lib/hooks/useNavigationTabState.web.ts index 704424781..e86d6c6c3 100644 --- a/src/lib/hooks/useNavigationTabState.web.ts +++ b/src/lib/hooks/useNavigationTabState.web.ts @@ -1,4 +1,5 @@ import {useNavigationState} from '@react-navigation/native' + import {getCurrentRoute} from 'lib/routes/helpers' export function useNavigationTabState() { @@ -9,6 +10,7 @@ export function useNavigationTabState() { isAtSearch: currentRoute === 'Search', isAtNotifications: currentRoute === 'Notifications', isAtMyProfile: currentRoute === 'MyProfile', + isAtMessages: currentRoute === 'Messages', } }) } diff --git a/src/lib/media/picker.tsx b/src/lib/media/picker.tsx index bf531c981..37e01e67f 100644 --- a/src/lib/media/picker.tsx +++ b/src/lib/media/picker.tsx @@ -1,8 +1,9 @@ import { + Image as RNImage, openCamera as openCameraFn, openCropper as openCropperFn, - Image as RNImage, } from 'react-native-image-crop-picker' + import {CameraOpts, CropperOptions} from './types' export {openPicker} from './picker.shared' diff --git a/src/lib/media/picker.web.tsx b/src/lib/media/picker.web.tsx index 995a0c95f..8782e1457 100644 --- a/src/lib/media/picker.web.tsx +++ b/src/lib/media/picker.web.tsx @@ -1,7 +1,8 @@ /// <reference lib="dom" /> -import {CameraOpts, CropperOptions} from './types' import {Image as RNImage} from 'react-native-image-crop-picker' + +import {CameraOpts, CropperOptions} from './types' export {openPicker} from './picker.shared' import {unstable__openModal} from '#/state/modals' @@ -16,6 +17,10 @@ export async function openCropper(opts: CropperOptions): Promise<RNImage> { unstable__openModal({ name: 'crop-image', uri: opts.path, + dimensions: + opts.height && opts.width + ? {width: opts.width, height: opts.height} + : undefined, onSelect: (img?: RNImage) => { if (img) { resolve(img) diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index f9a592711..f7e8544b8 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -72,7 +72,7 @@ export type MyProfileTabNavigatorParams = CommonNavigatorParams & { } export type MessagesTabNavigatorParams = CommonNavigatorParams & { - MessagesList: undefined + Messages: undefined } export type FlatNavigatorParams = CommonNavigatorParams & { @@ -81,7 +81,7 @@ export type FlatNavigatorParams = CommonNavigatorParams & { Feeds: undefined Notifications: undefined Hashtag: {tag: string; author?: string} - MessagesList: undefined + Messages: undefined } export type AllNavigatorParams = CommonNavigatorParams & { @@ -96,7 +96,7 @@ export type AllNavigatorParams = CommonNavigatorParams & { MyProfileTab: undefined Hashtag: {tag: string; author?: string} MessagesTab: undefined - MessagesList: undefined + Messages: undefined } // NOTE diff --git a/src/lib/statsig/gates.ts b/src/lib/statsig/gates.ts index 5cd603920..43e2086c2 100644 --- a/src/lib/statsig/gates.ts +++ b/src/lib/statsig/gates.ts @@ -1,10 +1,9 @@ export type Gate = // Keep this alphabetic please. | 'autoexpand_suggestions_on_profile_follow_v2' - | 'disable_min_shell_on_foregrounding_v2' + | 'disable_min_shell_on_foregrounding_v3' | 'disable_poll_on_discover_v2' | 'dms' - | 'hide_vertical_scroll_indicators' | 'show_follow_back_label_v2' | 'start_session_with_following_v2' | 'test_gate_1' diff --git a/src/lib/strings/helpers.ts b/src/lib/strings/helpers.ts index de4562d2c..b4ce64fa5 100644 --- a/src/lib/strings/helpers.ts +++ b/src/lib/strings/helpers.ts @@ -1,13 +1,3 @@ -export function pluralize(n: number, base: string, plural?: string): string { - if (n === 1) { - return base - } - if (plural) { - return plural - } - return base + 's' -} - export function enforceLen( str: string, len: number, |