Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApplicationGroup } from '@Lib/ApplicationGroup'
import { navigationRef } from '@Lib/NavigationService'
import { DefaultTheme, NavigationContainer } from '@react-navigation/native'
import { ApplicationGroupContext } from '@Root/ApplicationGroupContext'
import { EnvironmentContext } from '@Root/EnvironmentContext'
import { MobileThemeVariables } from '@Root/Style/Themes/styled-components'
import { ApplicationGroupEvent, DeinitMode, DeinitSource } from '@standardnotes/snjs'
import { ThemeService, ThemeServiceContext } from '@Style/ThemeService'
Expand Down Expand Up @@ -111,11 +112,13 @@ const AppComponent: React.FC<{
{themeService.current && (
<>
<ThemeProvider theme={activeTheme}>
<ActionSheetProvider>
<ThemeServiceContext.Provider value={themeService.current}>
<MainStackComponent env={env} />
</ThemeServiceContext.Provider>
</ActionSheetProvider>
<EnvironmentContext.Provider value={env}>
<ActionSheetProvider>
<ThemeServiceContext.Provider value={themeService.current}>
<MainStackComponent env={env} />
</ThemeServiceContext.Provider>
</ActionSheetProvider>
</EnvironmentContext.Provider>
<ToastWrapper />
</ThemeProvider>
</>
Expand Down
6 changes: 6 additions & 0 deletions packages/mobile/src/EnvironmentContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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>
8 changes: 8 additions & 0 deletions packages/mobile/src/Hooks/useSafeEnvironmentContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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
}
5 changes: 4 additions & 1 deletion packages/mobile/src/Lib/Interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IsDev } from '@Lib/Utils'
import AsyncStorage from '@react-native-community/async-storage'
import SNReactNative from '@standardnotes/react-native-utils'
import {
Expand Down Expand Up @@ -315,7 +316,9 @@ export class MobileDeviceInterface implements DeviceInterface {
}

performSoftReset() {
SNReactNative.exitApp()
if (IsDev) {
SNReactNative.exitApp()
}
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand Down
19 changes: 11 additions & 8 deletions packages/mobile/src/Screens/Settings/Sections/OptionsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useSignedIn } from '@Lib/SnjsHelperHooks'
import { isUnfinishedFeaturesEnabled } from '@Lib/Utils'
import { useNavigation } from '@react-navigation/native'
import { ButtonCell } from '@Root/Components/ButtonCell'
import { SectionedAccessoryTableCell } from '@Root/Components/SectionedAccessoryTableCell'
import { SectionedOptionsTableCell } from '@Root/Components/SectionedOptionsTableCell'
import { SectionHeader } from '@Root/Components/SectionHeader'
import { TableSection } from '@Root/Components/TableSection'
import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext'
import { useSafeEnvironmentContext } from '@Root/Hooks/useSafeEnvironmentContext'
import { ModalStackNavigationProp } from '@Root/ModalStack'
import { SCREEN_MANAGE_SESSIONS, SCREEN_SETTINGS } from '@Root/Screens/screens'
import { ButtonType, PrefKey } from '@standardnotes/snjs'
Expand All @@ -26,6 +28,7 @@ export const OptionsSection = ({ title, encryptionAvailable }: Props) => {

const [signedIn] = useSignedIn()
const navigation = useNavigation<ModalStackNavigationProp<typeof SCREEN_SETTINGS>['navigation']>()
const env = useSafeEnvironmentContext()

// State
const [importing, setImporting] = useState(false)
Expand Down Expand Up @@ -76,14 +79,14 @@ export const OptionsSection = ({ title, encryptionAvailable }: Props) => {
}, [encryptionAvailable])

const destroyLocalData = async () => {
if (
await application.alertService.confirm(
'Signing out will remove all data from this device, including notes and tags. Make sure your data is synced before proceeding.',
'Sign Out?',
'Sign Out',
ButtonType.Danger,
)
) {
let signoutText =
'Signing out will remove all data from this device, including notes and tags. Make sure your data is synced before proceeding.'

if (isUnfinishedFeaturesEnabled(env)) {
signoutText += '\n\nYour app will quit after sign out completes.'
}

if (await application.alertService.confirm(signoutText, 'Sign Out?', 'Sign Out', ButtonType.Danger)) {
await application.user.signOut()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const WorkspacesSection = () => {
break
case Remove:
message =
'This action will remove this workspace and its related data from this device. Your synced data will not be affected.'
'This action will remove this workspace and its related data from this device. Your synced data will not be affected.\n\nYour app will quit after workspace removal completes.'
buttonText = 'Delete Workspace'
buttonType = Danger
break
Expand Down
5 changes: 4 additions & 1 deletion packages/mobile/src/Screens/Settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useSignedIn } from '@Lib/SnjsHelperHooks'
import { isUnfinishedFeaturesEnabled } from '@Lib/Utils'
import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext'
import { useSafeEnvironmentContext } from '@Root/Hooks/useSafeEnvironmentContext'
import { ModalStackNavigationProp } from '@Root/ModalStack'
import { SCREEN_SETTINGS } from '@Root/Screens/screens'
import { FilesSection } from '@Screens/Settings/Sections/FilesSection'
Expand All @@ -20,6 +22,7 @@ type Props = ModalStackNavigationProp<typeof SCREEN_SETTINGS>
export const Settings = (props: Props) => {
// Context
const application = useSafeApplicationContext()
const env = useSafeEnvironmentContext()

// State
const [hasPasscode, setHasPasscode] = useState(() => Boolean(application.hasPasscode()))
Expand Down Expand Up @@ -55,7 +58,7 @@ export const Settings = (props: Props) => {
<Container keyboardShouldPersistTaps={'always'} keyboardDismissMode={'interactive'}>
<AuthSection title="Account" signedIn={signedIn} />
<OptionsSection encryptionAvailable={!!encryptionAvailable} title="Options" />
<WorkspacesSection />
{isUnfinishedFeaturesEnabled(env) && <WorkspacesSection />}
<PreferencesSection />
{application.hasAccount() && isEntitledToFiles && <FilesSection />}
<SecuritySection
Expand Down