Merge branch 'dev' into ez_bookmark

This commit is contained in:
zjs81 authored and GitHub committed 2026-11-15 15:16:18 -07:00
commit 89071473a5
49 files changed
+3932 -149

No files matched your search

+60
View File
@@ -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_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:shared_preferences/shared_preferences.dart';
@@ -211,6 +212,65 @@ void main() {
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', () {
@@ -826,6 +826,73 @@ void main() {
expect(h.decoder.calls, 0);
});
test('a decoded preview is labelled synthesized and keeps its byte count '
'and echoes', () async {
final h = _build();
final entry = await h.store.registerOutgoing(
channelIndex: 1,
senderPrefix: kSelf,
imgId: 4,
previewPng: Uint8List.fromList(List<int>.filled(64, 1)),
rate: AeicRatePoint.ft32,
chunkCount: 2,
synthesized: true,
payloadBytes: 171,
chunkEchoes: const [1, 0, 2],
);
expect(entry.synthesized, isTrue);
expect(entry.bitstreamByteCount, 171);
expect(entry.bitstreamStored, isFalse);
expect(entry.minDataChunkEchoes, 0);
final restored = ReceivedImageEntry.fromJson(entry.toJson());
expect(restored.synthesized, isTrue);
expect(restored.chunkEchoes, [1, 0, 2]);
});
test(
'setOutgoingEchoes updates the newest matching outgoing image',
() async {
final h = _build();
final older = await h.store.registerOutgoing(
channelIndex: 1,
senderPrefix: kSelf,
imgId: 9,
previewPng: Uint8List.fromList(List<int>.filled(64, 1)),
rate: AeicRatePoint.ft32,
chunkCount: 1,
);
h.advance(const Duration(seconds: 5));
final newer = await h.store.registerOutgoing(
channelIndex: 1,
senderPrefix: kSelf,
imgId: 9,
previewPng: Uint8List.fromList(List<int>.filled(64, 2)),
rate: AeicRatePoint.ft32,
chunkCount: 1,
);
await h.store.setOutgoingEchoes(
channelIndex: 1,
senderPrefix: kSelf,
imgId: 9,
echoes: const [3, 1],
);
expect(h.store.entryFor(newer.streamId)!.chunkEchoes, [3, 1]);
expect(h.store.entryFor(newer.streamId)!.minDataChunkEchoes, 3);
expect(h.store.entryFor(older.streamId)!.chunkEchoes, isNull);
// Another channel's image with the same id is left alone.
await h.store.setOutgoingEchoes(
channelIndex: 2,
senderPrefix: kSelf,
imgId: 9,
echoes: const [7, 7],
);
expect(h.store.entryFor(newer.streamId)!.chunkEchoes, [3, 1]);
},
);
test('spent outgoing entries count toward maxEntries', () async {
final h = _build(maxEntries: 2, maxAge: const Duration(minutes: 10));
final ids = <String>[];