ask for download models and fix problem with reloading discovered list after import.

This commit is contained in:
ericz committed 2026-11-08 14:13:33 +01:00
1 parent be28a1a258
commit a020eb30d0
32 files changed
+944 -9

No files matched your search

+4
View File
@@ -480,6 +480,10 @@ class BackupService {
);
}
}
if (!importingIdentity &&
selectedItems.contains(BackupItem.discoveredContacts)) {
await connector.reloadDiscoveredContacts();
}
if (replaceContacts) {
await _restoreRadioContacts(connector, destinationPublicKey);
}
+12 -4
View File
@@ -385,7 +385,7 @@ class ImageCodecService extends ChangeNotifier implements ImageSendCodec {
///
/// Call once at startup, next to
/// `await translationService.refreshDownloadedModels();` in `main.dart`.
Future<void> refreshDownloadedModels() async {
Future<void> refreshDownloadedModels({bool clearMissing = false}) async {
if (_isDownloading) return;
await _settingsStore.load();
if (kIsWeb) {
@@ -393,7 +393,7 @@ class ImageCodecService extends ChangeNotifier implements ImageSendCodec {
return;
}
final scanned = await _fileStore.scanDownloadedModels();
if (scanned.isEmpty) {
if (scanned.isEmpty && !clearMissing) {
_notify();
return;
}
@@ -405,6 +405,9 @@ class ImageCodecService extends ChangeNotifier implements ImageSendCodec {
final existingByPath = {
for (final model in preferences.downloadedModels) model.localPath: model,
};
final existingByName = {
for (final model in preferences.downloadedModels) model.name: model,
};
final merged = <ImageCodecModelRecord>[];
// Every filename the registry knows about, so a half-installed bundle's
// leftovers are never mistaken for standalone models.
@@ -457,9 +460,14 @@ class ImageCodecService extends ChangeNotifier implements ImageSendCodec {
// as its own single-file record so a hand-fetched graph is not deleted.
for (final model in scanned) {
if (claimed.contains(model.name)) continue;
final existing = existingByPath[model.localPath];
final existing =
existingByPath[model.localPath] ?? existingByName[model.name];
merged.add(
existing?.copyWith(fileSizeBytes: model.fileSizeBytes) ?? model,
existing?.copyWith(
localPath: model.localPath,
fileSizeBytes: model.fileSizeBytes,
) ??
model,
);
}
+9 -2
View File
@@ -142,18 +142,25 @@ class TranslationService extends ChangeNotifier {
return availableModels.isNotEmpty ? availableModels.first : null;
}
Future<void> refreshDownloadedModels() async {
Future<void> refreshDownloadedModels({bool clearMissing = false}) async {
if (_isDownloading) return;
final scanned = await _fileStore.scanDownloadedModels();
if (scanned.isEmpty && !clearMissing) return;
if (scanned.isEmpty) {
await _appSettingsService.setTranslationDownloadedModels(const []);
return;
}
final existingByPath = {
for (final model in _settings.translationDownloadedModels)
model.localPath: model,
};
final existingByName = {
for (final model in _settings.translationDownloadedModels)
model.name: model,
};
final merged = scanned.map((model) {
final existing = existingByPath[model.localPath];
final existing =
existingByPath[model.localPath] ?? existingByName[model.name];
if (existing == null) {
return model;
}