diff --git a/native/profile/backup-menu.react.js b/native/profile/backup-menu.react.js
--- a/native/profile/backup-menu.react.js
+++ b/native/profile/backup-menu.react.js
@@ -1,23 +1,46 @@
// @flow
import * as React from 'react';
-import { Switch, Text, View } from 'react-native';
+import { Alert, Switch, Text, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { useDispatch } from 'react-redux';
+import { getMessageForException } from 'lib/utils/errors.js';
+import { entries } from 'lib/utils/objects.js';
+
+import { useClientBackup } from '../backup/use-client-backup.js';
+import Button from '../components/button.react.js';
import { setLocalSettingsActionType } from '../redux/action-types.js';
import { useSelector } from '../redux/redux-utils.js';
-import { useStyles } from '../themes/colors.js';
+import { useColors, useStyles } from '../themes/colors.js';
// eslint-disable-next-line no-unused-vars
function BackupMenu(props: { ... }): React.Node {
const styles = useStyles(unboundStyles);
const dispatch = useDispatch();
+ const colors = useColors();
+ const userStore = useSelector(state => state.userStore);
const isBackupEnabled = useSelector(
state => state.localSettings.isBackupEnabled,
);
+ const { restoreBackupProtocol } = useClientBackup();
+
+ const testRestore = React.useCallback(async () => {
+ let message;
+ try {
+ const result = await restoreBackupProtocol({ userStore });
+ message = entries(result)
+ .map(([key, value]) => `${key}: ${value}`)
+ .join('\n');
+ } catch (e) {
+ console.error(`Backup uploading error: ${e}`);
+ message = `Backup restore error: ${String(getMessageForException(e))}`;
+ }
+ Alert.alert('Restore protocol result', message);
+ }, [restoreBackupProtocol, userStore]);
+
const onBackupToggled = React.useCallback(
value => {
dispatch({
@@ -40,6 +63,19 @@
+
+ ACTIONS
+
+
+
);
}
@@ -77,6 +113,12 @@
flex: 1,
fontSize: 16,
},
+ row: {
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ paddingHorizontal: 24,
+ paddingVertical: 14,
+ },
};
export default BackupMenu;