Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3386620
D9004.id30755.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9004.id30755.diff
View Options
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}: ${String(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 @@
<Switch value={isBackupEnabled} onValueChange={onBackupToggled} />
</View>
</View>
+
+ <Text style={styles.header}>ACTIONS</Text>
+ <View style={styles.section}>
+ <Button
+ onPress={testRestore}
+ style={styles.row}
+ iosFormat="highlight"
+ iosHighlightUnderlayColor={colors.panelIosHighlightUnderlay}
+ iosActiveOpacity={0.85}
+ >
+ <Text style={styles.submenuText}>Test backup restore protocol</Text>
+ </Button>
+ </View>
</ScrollView>
);
}
@@ -77,6 +113,12 @@
flex: 1,
fontSize: 16,
},
+ row: {
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ paddingHorizontal: 24,
+ paddingVertical: 14,
+ },
};
export default BackupMenu;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 5:24 AM (21 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599728
Default Alt Text
D9004.id30755.diff (2 KB)
Attached To
Mode
D9004: [client-backup] add restore test
Attached
Detach File
Event Timeline
Log In to Comment