diff --git a/native/backup/backup-handler.js b/native/backup/backup-handler.js --- a/native/backup/backup-handler.js +++ b/native/backup/backup-handler.js @@ -20,6 +20,9 @@ const currentUserID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); + const isBackupEnabled = useSelector( + state => state.localSettings.isBackupEnabled, + ); const loggedIn = useSelector(isLoggedIn); const isStaff = useIsCurrentUserStaff(); @@ -27,7 +30,7 @@ React.useEffect(() => { (async () => { - if (!loggedIn || !(isStaff || isDev)) { + if (!isBackupEnabled || !loggedIn || !(isStaff || isDev)) { return; } @@ -54,7 +57,14 @@ Alert.alert('Backup protocol result', message); } })(); - }, [currentUserID, isStaff, loggedIn, uploadBackupProtocol, userStore]); + }, [ + currentUserID, + isBackupEnabled, + isStaff, + loggedIn, + uploadBackupProtocol, + userStore, + ]); return null; } diff --git a/native/redux/action-types.js b/native/redux/action-types.js --- a/native/redux/action-types.js +++ b/native/redux/action-types.js @@ -10,6 +10,7 @@ import type { AppState } from './state-types.js'; import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; +import type { LocalSettings } from '../types/local-settings-types.js'; import type { GlobalThemeInfo } from '../types/themes.js'; export const updateDimensionsActiveType = 'UPDATE_DIMENSIONS'; @@ -21,6 +22,7 @@ 'UPDATE_THREAD_LAST_NAVIGATED'; export const setStoreLoadedActionType = 'SET_STORE_LOADED'; export const setReduxStateActionType = 'SET_REDUX_STATE'; +export const setLocalSettingsActionType = 'SET_LOCAL_SETTINGS'; export const backgroundActionTypes: Set = new Set([ saveMessagesActionType, @@ -62,4 +64,5 @@ } | { +type: 'SET_STORE_LOADED', - }; + } + | { +type: 'SET_LOCAL_SETTINGS', +payload: LocalSettings }; diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -43,6 +43,7 @@ setReduxStateActionType, setStoreLoadedActionType, type Action, + setLocalSettingsActionType, } from './action-types.js'; import { remoteReduxDevServerConfig } from './dev-tools.js'; import { defaultDimensionsInfo } from './dimensions-updater.react.js'; @@ -128,6 +129,9 @@ }, }, }, + localSettings: { + isBackupEnabled: false, + }, }: AppState); function reducer(state: AppState = defaultState, action: Action) { @@ -298,6 +302,11 @@ }); } return state; + } else if (action.type === setLocalSettingsActionType) { + return { + ...state, + localSettings: { ...state.localSettings, ...action.payload }, + }; } if (action.type === setNewSessionActionType) { diff --git a/native/redux/state-types.js b/native/redux/state-types.js --- a/native/redux/state-types.js +++ b/native/redux/state-types.js @@ -24,6 +24,7 @@ import type { NavInfo } from '../navigation/default-state.js'; import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; +import type { LocalSettings } from '../types/local-settings-types.js'; import type { GlobalThemeInfo } from '../types/themes.js'; export type AppState = { @@ -59,4 +60,5 @@ +inviteLinksStore: InviteLinksStore, +lastCommunicatedPlatformDetails: LastCommunicatedPlatformDetails, +keyserverStore: KeyserverStore, + +localSettings: LocalSettings, }; diff --git a/native/types/local-settings-types.js b/native/types/local-settings-types.js new file mode 100644 --- /dev/null +++ b/native/types/local-settings-types.js @@ -0,0 +1,5 @@ +// @flow + +export type LocalSettings = { + +isBackupEnabled: boolean, +};