From a21bcf10dd794b69009b98c7789a7e87d696bfef Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Sun, 20 Nov 2022 12:00:40 -0600 Subject: [PATCH] Add build flags and disable tabs for now --- src/build-flags.ts | 2 ++ src/state/index.ts | 1 - src/state/models/navigation.ts | 11 ++++++++++- src/view/com/modals/ServerInput.tsx | 4 ++-- src/view/com/onboard/FeatureExplainer.tsx | 5 +++-- src/view/com/util/DropdownBtn.tsx | 17 ++++++++++------- src/view/shell/mobile/index.tsx | 13 ++++++++----- 7 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 src/build-flags.ts diff --git a/src/build-flags.ts b/src/build-flags.ts new file mode 100644 index 00000000..155230e5 --- /dev/null +++ b/src/build-flags.ts @@ -0,0 +1,2 @@ +export const LOGIN_INCLUDE_DEV_SERVERS = true +export const TABS_ENABLED = false diff --git a/src/state/index.ts b/src/state/index.ts index fd81bc84..872cd69f 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -5,7 +5,6 @@ import {RootStoreModel} from './models/root-store' import * as libapi from './lib/api' import * as storage from './lib/storage' -export const IS_PROD_BUILD = true export const LOCAL_DEV_SERVICE = 'http://localhost:2583' export const STAGING_SERVICE = 'https://pds.staging.bsky.dev' export const PROD_SERVICE = 'https://bsky.social' diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 0ec097af..758ae37d 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -1,5 +1,5 @@ import {makeAutoObservable} from 'mobx' -import {isObj, hasProp} from '../lib/type-guards' +import {TABS_ENABLED} from '../../build-flags' let __id = 0 function genId() { @@ -226,6 +226,9 @@ export class NavigationModel { // = newTab(url: string, title?: string) { + if (!TABS_ENABLED) { + return this.navigate(url) + } const tab = new NavigationTabModel() tab.navigate(url, title) tab.isNewTab = true @@ -234,10 +237,16 @@ export class NavigationModel { } setActiveTab(tabIndex: number) { + if (!TABS_ENABLED) { + return + } this.tabIndex = Math.max(Math.min(tabIndex, this.tabs.length - 1), 0) } closeTab(tabIndex: number) { + if (!TABS_ENABLED) { + return + } this.tabs = [ ...this.tabs.slice(0, tabIndex), ...this.tabs.slice(tabIndex + 1), diff --git a/src/view/com/modals/ServerInput.tsx b/src/view/com/modals/ServerInput.tsx index 0aa1a07e..c885ff16 100644 --- a/src/view/com/modals/ServerInput.tsx +++ b/src/view/com/modals/ServerInput.tsx @@ -5,11 +5,11 @@ import {BottomSheetScrollView, BottomSheetTextInput} from '@gorhom/bottom-sheet' import {useStores} from '../../../state' import {s, colors} from '../../lib/styles' import { - IS_PROD_BUILD, LOCAL_DEV_SERVICE, STAGING_SERVICE, PROD_SERVICE, } from '../../../state/index' +import {LOGIN_INCLUDE_DEV_SERVERS} from '../../../build-flags' export const snapPoints = ['80%'] @@ -36,7 +36,7 @@ export function Component({ Choose Service - {!IS_PROD_BUILD ? ( + {LOGIN_INCLUDE_DEV_SERVERS ? ( <> ( @@ -85,8 +86,8 @@ export const FeatureExplainer = () => { const routes = [ {key: 'intro', title: 'Intro'}, {key: 'scenes', title: 'Scenes'}, - {key: 'tabs', title: 'Tabs'}, - ] + TABS_ENABLED ? {key: 'tabs', title: 'Tabs'} : undefined, + ].filter(Boolean) const onPressSkip = () => store.onboard.next() const onPressNext = () => { diff --git a/src/view/com/util/DropdownBtn.tsx b/src/view/com/util/DropdownBtn.tsx index bef193f1..85e8453f 100644 --- a/src/view/com/util/DropdownBtn.tsx +++ b/src/view/com/util/DropdownBtn.tsx @@ -14,6 +14,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {colors} from '../../lib/styles' import {useStores} from '../../../state' import {SharePostModel, ConfirmModel} from '../../../state/models/shell-ui' +import {TABS_ENABLED} from '../../../build-flags' export interface DropdownItem { icon?: IconProp @@ -82,13 +83,15 @@ export function PostDropdownBtn({ const store = useStores() const dropdownItems: DropdownItem[] = [ - { - icon: ['far', 'clone'], - label: 'Open in new tab', - onPress() { - store.nav.newTab(itemHref) - }, - }, + TABS_ENABLED + ? { + icon: ['far', 'clone'], + label: 'Open in new tab', + onPress() { + store.nav.newTab(itemHref) + }, + } + : undefined, { icon: 'share', label: 'Share...', diff --git a/src/view/shell/mobile/index.tsx b/src/view/shell/mobile/index.tsx index e0f7c07a..32b1f35d 100644 --- a/src/view/shell/mobile/index.tsx +++ b/src/view/shell/mobile/index.tsx @@ -26,6 +26,7 @@ import Animated, { } from 'react-native-reanimated' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {IconProp} from '@fortawesome/fontawesome-svg-core' +import {TABS_ENABLED} from '../../../build-flags' import {useStores} from '../../../state' import {NavigationModel} from '../../../state/models/navigation' import {match, MatchResult} from '../../routes' @@ -331,11 +332,13 @@ export const MobileShell: React.FC = observer(() => { onPress={onPressSearch} onLongPress={doNewTab('/search')} /> - + {TABS_ENABLED ? ( + + ) : undefined}