Fix backup restore settings and ordering
Apply restored eviction and list sorting settings before reloading data; stabilize the message-filter ingestion test against queued review history.
This commit is contained in:
1 parent
c0702806de
commit
37bfdd47fe
7 files changed
+94
No files matched your search
@@ -2133,6 +2133,8 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> reloadChannelOrder() => _loadChannelOrder();
|
||||||
|
|
||||||
/// History is stored by channel ID, so it may carry the slot the channel
|
/// History is stored by channel ID, so it may carry the slot the channel
|
||||||
/// sat in when it was saved; rebind it to the slot it is shown in now.
|
/// sat in when it was saved; rebind it to the slot it is shown in now.
|
||||||
List<ChannelMessage> _bindToSlot(List<ChannelMessage> messages, int slot) => [
|
List<ChannelMessage> _bindToSlot(List<ChannelMessage> messages, int slot) => [
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import '../services/app_settings_service.dart';
|
|||||||
import '../services/backup_service.dart';
|
import '../services/backup_service.dart';
|
||||||
import '../services/image_codec_service.dart';
|
import '../services/image_codec_service.dart';
|
||||||
import '../services/translation_service.dart';
|
import '../services/translation_service.dart';
|
||||||
|
import '../services/ui_view_state_service.dart';
|
||||||
import '../services/message_filter/message_filter_service.dart';
|
import '../services/message_filter/message_filter_service.dart';
|
||||||
import '../utils/platform_info.dart';
|
import '../utils/platform_info.dart';
|
||||||
import '../utils/share_origin.dart';
|
import '../utils/share_origin.dart';
|
||||||
@@ -432,6 +433,7 @@ class _BackupRestoreScreenState extends State<BackupRestoreScreen> {
|
|||||||
final l10n = context.l10n;
|
final l10n = context.l10n;
|
||||||
final connector = context.read<MeshCoreConnector>();
|
final connector = context.read<MeshCoreConnector>();
|
||||||
final appSettingsService = context.read<AppSettingsService>();
|
final appSettingsService = context.read<AppSettingsService>();
|
||||||
|
final uiViewStateService = context.read<UiViewStateService>();
|
||||||
final messageFilterService = context.read<MessageFilterService>();
|
final messageFilterService = context.read<MessageFilterService>();
|
||||||
final translationService = context.read<TranslationService>();
|
final translationService = context.read<TranslationService>();
|
||||||
final imageCodecService = context.read<ImageCodecService>();
|
final imageCodecService = context.read<ImageCodecService>();
|
||||||
@@ -454,6 +456,7 @@ class _BackupRestoreScreenState extends State<BackupRestoreScreen> {
|
|||||||
)) {
|
)) {
|
||||||
await appSettingsService.loadSettings();
|
await appSettingsService.loadSettings();
|
||||||
if (_selectedItems.contains(BackupItem.appSettings)) {
|
if (_selectedItems.contains(BackupItem.appSettings)) {
|
||||||
|
await uiViewStateService.reload();
|
||||||
await _offerMissingModels(
|
await _offerMissingModels(
|
||||||
appSettingsService,
|
appSettingsService,
|
||||||
translationService,
|
translationService,
|
||||||
|
|||||||
@@ -485,6 +485,12 @@ class BackupService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selectedItems.contains(BackupItem.appSettings)) {
|
||||||
|
await appSettingsService.loadSettings();
|
||||||
|
}
|
||||||
|
if (selectedItems.contains(BackupItem.channelSettings)) {
|
||||||
|
await connector.reloadChannelOrder();
|
||||||
|
}
|
||||||
if (!importingIdentity &&
|
if (!importingIdentity &&
|
||||||
selectedItems.contains(BackupItem.discoveredContacts)) {
|
selectedItems.contains(BackupItem.discoveredContacts)) {
|
||||||
await connector.reloadDiscoveredContacts();
|
await connector.reloadDiscoveredContacts();
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ class UiViewStateService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> reload() async {
|
||||||
|
await initialize();
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void setContactsSelectedGroupName(String value) {
|
void setContactsSelectedGroupName(String value) {
|
||||||
if (_contactsSelectedGroupName == value) return;
|
if (_contactsSelectedGroupName == value) return;
|
||||||
_contactsSelectedGroupName = value;
|
_contactsSelectedGroupName = value;
|
||||||
|
|||||||
@@ -259,6 +259,19 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test('reloads a restored custom channel order', () async {
|
||||||
|
await _connect(_TestRadio());
|
||||||
|
final restoredOrder = [_id(_psk(1)), _id(_psk(0)), _id(_psk(2))];
|
||||||
|
await PrefsManager.instance.setString(
|
||||||
|
'channel_order_$_scope',
|
||||||
|
jsonEncode(restoredOrder),
|
||||||
|
);
|
||||||
|
|
||||||
|
await _connector.reloadChannelOrder();
|
||||||
|
|
||||||
|
expect(_connector.channels.first.storageId, restoredOrder.first);
|
||||||
|
});
|
||||||
|
|
||||||
test('deleting a channel clears its stored history', () async {
|
test('deleting a channel clears its stored history', () async {
|
||||||
await _connect(_TestRadio());
|
await _connect(_TestRadio());
|
||||||
await _waitFor(() => _texts(1).contains(_queuedHikingText));
|
await _waitFor(() => _texts(1).contains(_queuedHikingText));
|
||||||
|
|||||||
@@ -410,6 +410,11 @@ void main() {
|
|||||||
|
|
||||||
test('mesh copies of one message are stored and filtered once', () async {
|
test('mesh copies of one message are stored and filtered once', () async {
|
||||||
await _connect();
|
await _connect();
|
||||||
|
await _waitFor(
|
||||||
|
() => ReviewScript.seedChannelMessages.every(
|
||||||
|
(message) => _find(message.channelIndex, message.text) != null,
|
||||||
|
),
|
||||||
|
);
|
||||||
const text = 'Weather net starts at seven tonight on the hill';
|
const text = 'Weather net starts at seven tonight on the hill';
|
||||||
final ts = _nowSecs();
|
final ts = _nowSecs();
|
||||||
final cleanBefore = _filter.recentCleanCount;
|
final cleanBefore = _filter.recentCleanCount;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import 'package:meshcore_open/services/image_codec_settings_store.dart';
|
|||||||
import 'package:meshcore_open/services/translation_file_store.dart';
|
import 'package:meshcore_open/services/translation_file_store.dart';
|
||||||
import 'package:meshcore_open/services/translation_service.dart';
|
import 'package:meshcore_open/services/translation_service.dart';
|
||||||
import 'package:meshcore_open/services/backup_service.dart';
|
import 'package:meshcore_open/services/backup_service.dart';
|
||||||
|
import 'package:meshcore_open/services/ui_view_state_service.dart';
|
||||||
import 'package:meshcore_open/storage/prefs_manager.dart';
|
import 'package:meshcore_open/storage/prefs_manager.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
@@ -211,6 +212,65 @@ void main() {
|
|||||||
expect(restored['map_tile_api_key'], 'existing-stadia');
|
expect(restored['map_tile_api_key'], 'existing-stadia');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test('applies restored app settings to the live service', () async {
|
||||||
|
SharedPreferences.setMockInitialValues({
|
||||||
|
'app_settings': jsonEncode({'evict_discovered_contacts_enabled': true}),
|
||||||
|
});
|
||||||
|
PrefsManager.reset();
|
||||||
|
await PrefsManager.initialize();
|
||||||
|
addTearDown(PrefsManager.reset);
|
||||||
|
final connector = MeshCoreConnector();
|
||||||
|
final settingsService = AppSettingsService();
|
||||||
|
addTearDown(connector.dispose);
|
||||||
|
addTearDown(settingsService.dispose);
|
||||||
|
await settingsService.loadSettings();
|
||||||
|
|
||||||
|
final backup = await BackupService.encodeBackup({
|
||||||
|
'format': 'meshcore-open-backup',
|
||||||
|
'version': 1,
|
||||||
|
'sourcePublicKey': '',
|
||||||
|
'items': [BackupItem.appSettings.name],
|
||||||
|
'sections': {
|
||||||
|
'appSettings': {
|
||||||
|
'preferences': {
|
||||||
|
'app_settings': {'evict_discovered_contacts_enabled': false},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, password: '');
|
||||||
|
await const BackupService().restoreBackup(
|
||||||
|
contents: backup,
|
||||||
|
password: '',
|
||||||
|
items: {BackupItem.appSettings},
|
||||||
|
connector: connector,
|
||||||
|
appSettingsService: settingsService,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(settingsService.settings.evictDiscoveredContactsEnabled, isFalse);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
group('UiViewStateService reload', () {
|
||||||
|
test('notifies listeners with restored sort preferences', () async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
PrefsManager.reset();
|
||||||
|
await PrefsManager.initialize();
|
||||||
|
addTearDown(PrefsManager.reset);
|
||||||
|
final viewState = UiViewStateService();
|
||||||
|
addTearDown(viewState.dispose);
|
||||||
|
await viewState.initialize();
|
||||||
|
var notifications = 0;
|
||||||
|
viewState.addListener(() => notifications++);
|
||||||
|
|
||||||
|
await PrefsManager.instance.setString('ui_contacts_sort_option', 'name');
|
||||||
|
await PrefsManager.instance.setString('ui_channels_sort_option', 'name');
|
||||||
|
await viewState.reload();
|
||||||
|
|
||||||
|
expect(viewState.contactsSortOption.name, 'name');
|
||||||
|
expect(viewState.channelsSortOption, ChannelSortOption.name);
|
||||||
|
expect(notifications, 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('restored model registry reconciliation', () {
|
group('restored model registry reconciliation', () {
|
||||||
|
|||||||
Reference in new issue
Block a user