fix: use a specific feature flag for workspace (#1133)

This commit is contained in:
Vardan Hakobyan
2022-06-22 00:38:40 +04:00
committed by GitHub
parent 13cb655d1c
commit b25919099f
7 changed files with 15 additions and 32 deletions

View File

@@ -5,7 +5,6 @@ import { ApplicationGroup } from '@Lib/ApplicationGroup'
import { navigationRef } from '@Lib/NavigationService' import { navigationRef } from '@Lib/NavigationService'
import { DefaultTheme, NavigationContainer } from '@react-navigation/native' import { DefaultTheme, NavigationContainer } from '@react-navigation/native'
import { ApplicationGroupContext } from '@Root/ApplicationGroupContext' import { ApplicationGroupContext } from '@Root/ApplicationGroupContext'
import { EnvironmentContext } from '@Root/EnvironmentContext'
import { MobileThemeVariables } from '@Root/Style/Themes/styled-components' import { MobileThemeVariables } from '@Root/Style/Themes/styled-components'
import { ApplicationGroupEvent, DeinitMode, DeinitSource } from '@standardnotes/snjs' import { ApplicationGroupEvent, DeinitMode, DeinitSource } from '@standardnotes/snjs'
import { ThemeService, ThemeServiceContext } from '@Style/ThemeService' import { ThemeService, ThemeServiceContext } from '@Style/ThemeService'
@@ -112,13 +111,11 @@ const AppComponent: React.FC<{
{themeService.current && ( {themeService.current && (
<> <>
<ThemeProvider theme={activeTheme}> <ThemeProvider theme={activeTheme}>
<EnvironmentContext.Provider value={env}> <ActionSheetProvider>
<ActionSheetProvider> <ThemeServiceContext.Provider value={themeService.current}>
<ThemeServiceContext.Provider value={themeService.current}> <MainStackComponent env={env} />
<MainStackComponent env={env} /> </ThemeServiceContext.Provider>
</ThemeServiceContext.Provider> </ActionSheetProvider>
</ActionSheetProvider>
</EnvironmentContext.Provider>
<ToastWrapper /> <ToastWrapper />
</ThemeProvider> </ThemeProvider>
</> </>

View File

@@ -1,6 +0,0 @@
import { TEnvironment } from '@Root/App'
import React from 'react'
export const EnvironmentContext = React.createContext<TEnvironment | undefined>(undefined)
export const SafeEnvironmentContext = EnvironmentContext as React.Context<TEnvironment>

View File

@@ -1,8 +0,0 @@
import { TEnvironment } from '@Root/App'
import { EnvironmentContext } from '@Root/EnvironmentContext'
import { useContext } from 'react'
export const useSafeEnvironmentContext = () => {
const env = useContext(EnvironmentContext) as TEnvironment
return env
}

View File

@@ -1,4 +1,4 @@
import { IsDev } from '@Lib/Utils' import { WorkspacesEnabled } from '@Lib/constants'
import AsyncStorage from '@react-native-community/async-storage' import AsyncStorage from '@react-native-community/async-storage'
import SNReactNative from '@standardnotes/react-native-utils' import SNReactNative from '@standardnotes/react-native-utils'
import { import {
@@ -316,7 +316,7 @@ export class MobileDeviceInterface implements DeviceInterface {
} }
performSoftReset() { performSoftReset() {
if (IsDev) { if (WorkspacesEnabled) {
SNReactNative.exitApp() SNReactNative.exitApp()
} }
} }

View File

@@ -1,3 +1,7 @@
import { IsDev } from '@Lib/Utils'
export enum ErrorMessage { export enum ErrorMessage {
GeneralText = 'An error occurred. Please try again later.', GeneralText = 'An error occurred. Please try again later.',
} }
export const WorkspacesEnabled = IsDev

View File

@@ -1,5 +1,5 @@
import { WorkspacesEnabled } from '@Lib/constants'
import { useSignedIn } from '@Lib/SnjsHelperHooks' import { useSignedIn } from '@Lib/SnjsHelperHooks'
import { isUnfinishedFeaturesEnabled } from '@Lib/Utils'
import { useNavigation } from '@react-navigation/native' import { useNavigation } from '@react-navigation/native'
import { ButtonCell } from '@Root/Components/ButtonCell' import { ButtonCell } from '@Root/Components/ButtonCell'
import { SectionedAccessoryTableCell } from '@Root/Components/SectionedAccessoryTableCell' import { SectionedAccessoryTableCell } from '@Root/Components/SectionedAccessoryTableCell'
@@ -7,7 +7,6 @@ import { SectionedOptionsTableCell } from '@Root/Components/SectionedOptionsTabl
import { SectionHeader } from '@Root/Components/SectionHeader' import { SectionHeader } from '@Root/Components/SectionHeader'
import { TableSection } from '@Root/Components/TableSection' import { TableSection } from '@Root/Components/TableSection'
import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext' import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext'
import { useSafeEnvironmentContext } from '@Root/Hooks/useSafeEnvironmentContext'
import { ModalStackNavigationProp } from '@Root/ModalStack' import { ModalStackNavigationProp } from '@Root/ModalStack'
import { SCREEN_MANAGE_SESSIONS, SCREEN_SETTINGS } from '@Root/Screens/screens' import { SCREEN_MANAGE_SESSIONS, SCREEN_SETTINGS } from '@Root/Screens/screens'
import { ButtonType, PrefKey } from '@standardnotes/snjs' import { ButtonType, PrefKey } from '@standardnotes/snjs'
@@ -28,7 +27,6 @@ export const OptionsSection = ({ title, encryptionAvailable }: Props) => {
const [signedIn] = useSignedIn() const [signedIn] = useSignedIn()
const navigation = useNavigation<ModalStackNavigationProp<typeof SCREEN_SETTINGS>['navigation']>() const navigation = useNavigation<ModalStackNavigationProp<typeof SCREEN_SETTINGS>['navigation']>()
const env = useSafeEnvironmentContext()
// State // State
const [importing, setImporting] = useState(false) const [importing, setImporting] = useState(false)
@@ -82,7 +80,7 @@ export const OptionsSection = ({ title, encryptionAvailable }: Props) => {
let signoutText = let signoutText =
'Signing out will remove all data from this device, including notes and tags. Make sure your data is synced before proceeding.' 'Signing out will remove all data from this device, including notes and tags. Make sure your data is synced before proceeding.'
if (isUnfinishedFeaturesEnabled(env)) { if (WorkspacesEnabled) {
signoutText += '\n\nYour app will quit after sign out completes.' signoutText += '\n\nYour app will quit after sign out completes.'
} }

View File

@@ -1,7 +1,6 @@
import { WorkspacesEnabled } from '@Lib/constants'
import { useSignedIn } from '@Lib/SnjsHelperHooks' import { useSignedIn } from '@Lib/SnjsHelperHooks'
import { isUnfinishedFeaturesEnabled } from '@Lib/Utils'
import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext' import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext'
import { useSafeEnvironmentContext } from '@Root/Hooks/useSafeEnvironmentContext'
import { ModalStackNavigationProp } from '@Root/ModalStack' import { ModalStackNavigationProp } from '@Root/ModalStack'
import { SCREEN_SETTINGS } from '@Root/Screens/screens' import { SCREEN_SETTINGS } from '@Root/Screens/screens'
import { FilesSection } from '@Screens/Settings/Sections/FilesSection' import { FilesSection } from '@Screens/Settings/Sections/FilesSection'
@@ -22,7 +21,6 @@ type Props = ModalStackNavigationProp<typeof SCREEN_SETTINGS>
export const Settings = (props: Props) => { export const Settings = (props: Props) => {
// Context // Context
const application = useSafeApplicationContext() const application = useSafeApplicationContext()
const env = useSafeEnvironmentContext()
// State // State
const [hasPasscode, setHasPasscode] = useState(() => Boolean(application.hasPasscode())) const [hasPasscode, setHasPasscode] = useState(() => Boolean(application.hasPasscode()))
@@ -58,7 +56,7 @@ export const Settings = (props: Props) => {
<Container keyboardShouldPersistTaps={'always'} keyboardDismissMode={'interactive'}> <Container keyboardShouldPersistTaps={'always'} keyboardDismissMode={'interactive'}>
<AuthSection title="Account" signedIn={signedIn} /> <AuthSection title="Account" signedIn={signedIn} />
<OptionsSection encryptionAvailable={!!encryptionAvailable} title="Options" /> <OptionsSection encryptionAvailable={!!encryptionAvailable} title="Options" />
{isUnfinishedFeaturesEnabled(env) && <WorkspacesSection />} {WorkspacesEnabled && <WorkspacesSection />}
<PreferencesSection /> <PreferencesSection />
{application.hasAccount() && isEntitledToFiles && <FilesSection />} {application.hasAccount() && isEntitledToFiles && <FilesSection />}
<SecuritySection <SecuritySection