Fixes for restore from backup file. Fixed restoring for pin length. Added new transaction priority keys to preferences dump.CAKE-197. CAKE-247
M committed
Jan 27, 2021 at 19:26 UTC
b6215389d7ca23634322a7ad548595162c22249e
1 file changed
+18
-11
lib/core/backup_service.dart
+18
-11
@@ -126,7 +126,6 @@ class BackupService {
126
Future<void> _importPreferencesDump() async {
127
final appDir = await getApplicationDocumentsDirectory();
128
final preferencesFile = File('${appDir.path}/~_preferences_dump');
129
- const defaultSettingsMigrationVersionKey = PreferencesKey.currentDefaultSettingsMigrationVersion;
129
130
if (!preferencesFile.existsSync()) {
131
return;
@@ -157,14 +156,21 @@ class BackupService {
156
await _sharedPreferences.setInt(
157
PreferencesKey.currentBitcoinElectrumSererIdKey,
158
data[PreferencesKey.currentBitcoinElectrumSererIdKey] as int);
160
- await _sharedPreferences.setInt(PreferencesKey.currentLanguageCode,
161
- data[PreferencesKey.currentLanguageCode] as int);
159
+ await _sharedPreferences.setString(PreferencesKey.currentLanguageCode,
160
+ data[PreferencesKey.currentLanguageCode] as String);
161
await _sharedPreferences.setInt(PreferencesKey.displayActionListModeKey,
162
data[PreferencesKey.displayActionListModeKey] as int);
163
+ await _sharedPreferences.setInt(PreferencesKey.currentPinLength,
164
+ data[PreferencesKey.currentPinLength] as int);
165
await _sharedPreferences.setInt(
165
- 'current_theme', data['current_theme'] as int);
166
- await _sharedPreferences.setInt(defaultSettingsMigrationVersionKey,
167
- data[defaultSettingsMigrationVersionKey] as int);
166
+ PreferencesKey.currentTheme, data[PreferencesKey.currentTheme] as int);
167
+ await _sharedPreferences.setInt(
168
+ PreferencesKey.currentDefaultSettingsMigrationVersion,
169
+ data[PreferencesKey.currentDefaultSettingsMigrationVersion] as int);
170
+ await _sharedPreferences.setInt(PreferencesKey.moneroTransactionPriority,
171
+ data[PreferencesKey.moneroTransactionPriority] as int);
172
+ await _sharedPreferences.setInt(PreferencesKey.bitcoinTransactionPriority,
173
+ data[PreferencesKey.bitcoinTransactionPriority] as int);
174
175
await preferencesFile.delete();
176
}
@@ -237,9 +243,6 @@ class BackupService {
243
}
244
245
Future<String> _exportPreferencesJSON() async {
240
- const defaultSettingsMigrationVersionKey =
241
- 'current_default_settings_migration_version';
242
-
246
final preferences = <String, Object>{
247
PreferencesKey.currentWalletName:
248
_sharedPreferences.getString(PreferencesKey.currentWalletName),
@@ -269,8 +272,12 @@ class BackupService {
272
_sharedPreferences.getInt(PreferencesKey.displayActionListModeKey),
273
PreferencesKey.currentTheme:
274
_sharedPreferences.getInt(PreferencesKey.currentTheme),
272
- defaultSettingsMigrationVersionKey:
273
- _sharedPreferences.getInt(defaultSettingsMigrationVersionKey)
275
+ PreferencesKey.currentDefaultSettingsMigrationVersion: _sharedPreferences
276
+ .getInt(PreferencesKey.currentDefaultSettingsMigrationVersion),
277
+ PreferencesKey.bitcoinTransactionPriority:
278
+ _sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority),
279
+ PreferencesKey.moneroTransactionPriority:
280
+ _sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority),
281
};
282
283
return json.encode(preferences);