ask for download models and fix problem with reloading discovered list after import.
This commit is contained in:
1 parent
be28a1a258
commit
a020eb30d0
32 files changed
+944
-9
No files matched your search
@@ -605,6 +605,12 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
return List.unmodifiable(_discoveredContacts);
|
||||
}
|
||||
|
||||
Future<void> reloadDiscoveredContacts() async {
|
||||
if (!isConnected) return;
|
||||
await _loadDiscoveredContactCache();
|
||||
await updateKnownDiscovered();
|
||||
}
|
||||
|
||||
String exportDiscoveredContactsJson() {
|
||||
return _discoveryContactStore.exportContactsJson(_discoveredContacts);
|
||||
}
|
||||
|
||||
@@ -235,6 +235,16 @@
|
||||
"backupRestore_restore": "Restore Selected",
|
||||
"backupRestore_backupComplete": "Backup file created.",
|
||||
"backupRestore_restoreComplete": "Restore complete. Reconnect if you restored the radio identity.",
|
||||
"backupRestore_missingModelsTitle": "Models Not Downloaded",
|
||||
"backupRestore_missingModelsMessage": "The restored settings select models that are not available on this device:\n{models}\n\nDownload them now?",
|
||||
"@backupRestore_missingModelsMessage": {
|
||||
"placeholders": {
|
||||
"models": {"type": "String"}
|
||||
}
|
||||
},
|
||||
"backupRestore_downloadModels": "Download Models",
|
||||
"backupRestore_downloading": "Downloading…",
|
||||
"backupRestore_cancelDownload": "Cancel Download",
|
||||
"backupRestore_failed": "Backup operation failed: {error}",
|
||||
"@backupRestore_failed": {
|
||||
"placeholders": {
|
||||
|
||||
@@ -1084,6 +1084,36 @@ abstract class AppLocalizations {
|
||||
/// **'Restore complete. Reconnect if you restored the radio identity.'**
|
||||
String get backupRestore_restoreComplete;
|
||||
|
||||
/// No description provided for @backupRestore_missingModelsTitle.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Models Not Downloaded'**
|
||||
String get backupRestore_missingModelsTitle;
|
||||
|
||||
/// No description provided for @backupRestore_missingModelsMessage.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'The restored settings select models that are not available on this device:\n{models}\n\nDownload them now?'**
|
||||
String backupRestore_missingModelsMessage(String models);
|
||||
|
||||
/// No description provided for @backupRestore_downloadModels.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Download Models'**
|
||||
String get backupRestore_downloadModels;
|
||||
|
||||
/// No description provided for @backupRestore_downloading.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Downloading…'**
|
||||
String get backupRestore_downloading;
|
||||
|
||||
/// No description provided for @backupRestore_cancelDownload.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Cancel Download'**
|
||||
String get backupRestore_cancelDownload;
|
||||
|
||||
/// No description provided for @backupRestore_failed.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -544,6 +544,23 @@ class AppLocalizationsBg extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -547,6 +547,23 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -540,6 +540,23 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -545,6 +545,23 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -547,6 +547,23 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -543,6 +543,23 @@ class AppLocalizationsHu extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -547,6 +547,23 @@ class AppLocalizationsIt extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -528,6 +528,23 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -528,6 +528,23 @@ class AppLocalizationsKo extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -543,6 +543,23 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -550,6 +550,23 @@ class AppLocalizationsPl extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -546,6 +546,23 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -546,6 +546,23 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -546,6 +546,23 @@ class AppLocalizationsSk extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -545,6 +545,23 @@ class AppLocalizationsSl extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -541,6 +541,23 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -545,6 +545,23 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -522,6 +522,23 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
String get backupRestore_restoreComplete =>
|
||||
'Restore complete. Reconnect if you restored the radio identity.';
|
||||
|
||||
@override
|
||||
String get backupRestore_missingModelsTitle => 'Models Not Downloaded';
|
||||
|
||||
@override
|
||||
String backupRestore_missingModelsMessage(String models) {
|
||||
return 'The restored settings select models that are not available on this device:\n$models\n\nDownload them now?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get backupRestore_downloadModels => 'Download Models';
|
||||
|
||||
@override
|
||||
String get backupRestore_downloading => 'Downloading…';
|
||||
|
||||
@override
|
||||
String get backupRestore_cancelDownload => 'Cancel Download';
|
||||
|
||||
@override
|
||||
String backupRestore_failed(String error) {
|
||||
return 'Backup operation failed: $error';
|
||||
|
||||
@@ -110,6 +110,7 @@ class AppSettings {
|
||||
final bool mapShowChatNodes;
|
||||
final bool mapShowOtherNodes;
|
||||
final bool mapShowOnlineLinks;
|
||||
final bool mapUseOnlineMapForPaths;
|
||||
final bool mapShowOverlaps;
|
||||
final double mapTimeFilterHours; // 0 = all time
|
||||
final bool mapKeyPrefixEnabled;
|
||||
@@ -263,6 +264,7 @@ class AppSettings {
|
||||
this.mapShowChatNodes = true,
|
||||
this.mapShowOtherNodes = true,
|
||||
this.mapShowOnlineLinks = true,
|
||||
this.mapUseOnlineMapForPaths = false,
|
||||
this.mapShowOverlaps = false,
|
||||
this.mapTimeFilterHours = 168,
|
||||
this.mapKeyPrefixEnabled = false,
|
||||
@@ -359,6 +361,7 @@ class AppSettings {
|
||||
'map_show_chat_nodes': mapShowChatNodes,
|
||||
'map_show_other_nodes': mapShowOtherNodes,
|
||||
'map_show_online_links': mapShowOnlineLinks,
|
||||
'map_use_online_map_for_paths': mapUseOnlineMapForPaths,
|
||||
'map_show_overlaps': mapShowOverlaps,
|
||||
'map_time_filter_hours': mapTimeFilterHours,
|
||||
'map_key_prefix_enabled': mapKeyPrefixEnabled,
|
||||
@@ -492,6 +495,8 @@ class AppSettings {
|
||||
mapShowChatNodes: json['map_show_chat_nodes'] as bool? ?? true,
|
||||
mapShowOtherNodes: json['map_show_other_nodes'] as bool? ?? true,
|
||||
mapShowOnlineLinks: json['map_show_online_links'] as bool? ?? true,
|
||||
mapUseOnlineMapForPaths:
|
||||
json['map_use_online_map_for_paths'] as bool? ?? false,
|
||||
mapShowOverlaps: json['map_show_overlaps'] as bool? ?? false,
|
||||
mapTimeFilterHours:
|
||||
(json['map_time_filter_hours'] as num?)?.toDouble() ?? 168,
|
||||
@@ -666,6 +671,7 @@ class AppSettings {
|
||||
bool? mapShowChatNodes,
|
||||
bool? mapShowOtherNodes,
|
||||
bool? mapShowOnlineLinks,
|
||||
bool? mapUseOnlineMapForPaths,
|
||||
bool? mapShowOverlaps,
|
||||
double? mapTimeFilterHours,
|
||||
bool? mapKeyPrefixEnabled,
|
||||
@@ -746,6 +752,8 @@ class AppSettings {
|
||||
mapShowChatNodes: mapShowChatNodes ?? this.mapShowChatNodes,
|
||||
mapShowOtherNodes: mapShowOtherNodes ?? this.mapShowOtherNodes,
|
||||
mapShowOnlineLinks: mapShowOnlineLinks ?? this.mapShowOnlineLinks,
|
||||
mapUseOnlineMapForPaths:
|
||||
mapUseOnlineMapForPaths ?? this.mapUseOnlineMapForPaths,
|
||||
mapShowOverlaps: mapShowOverlaps ?? this.mapShowOverlaps,
|
||||
mapTimeFilterHours: mapTimeFilterHours ?? this.mapTimeFilterHours,
|
||||
mapKeyPrefixEnabled: mapKeyPrefixEnabled ?? this.mapKeyPrefixEnabled,
|
||||
|
||||
@@ -481,6 +481,19 @@ class ImageCodecModelSpec {
|
||||
maybeAssetFor(ImageCodecAssetRole.entropyGraph) != null &&
|
||||
maybeAssetFor(ImageCodecAssetRole.entropyDecodeGraph) != null &&
|
||||
maybeAssetFor(ImageCodecAssetRole.cdfTables) != null;
|
||||
|
||||
bool hasCompleteInstalledRecord(
|
||||
Iterable<ImageCodecModelRecord> downloadedModels,
|
||||
) => downloadedModels.any(
|
||||
(record) =>
|
||||
record.id == id &&
|
||||
record.bundleVersion >= kImageCodecBundleVersion &&
|
||||
assets.every(
|
||||
(asset) =>
|
||||
record.assetFileNames.contains(asset.fileName) &&
|
||||
record.assetRoles[asset.fileName] == asset.role,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The set of on-disk paths a codec session needs, replacing the bare
|
||||
|
||||
@@ -942,7 +942,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final alreadyHave = codec.availableModels.any((m) => m.id == spec.id);
|
||||
final alreadyHave = spec.hasCompleteInstalledRecord(codec.availableModels);
|
||||
// downloadPresetModel throws StateError on a placeholder URL, deliberately,
|
||||
// so the button must not be offerable until the weights are published.
|
||||
final blocked = spec.urlsArePlaceholders;
|
||||
@@ -1001,7 +1001,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
final l10n = context.l10n;
|
||||
try {
|
||||
await codec.downloadPresetModel(spec);
|
||||
} on Exception catch (error) {
|
||||
} catch (error) {
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(l10n.imageMessages_downloadFailedWithError('$error')),
|
||||
|
||||
@@ -10,8 +10,12 @@ import 'package:share_plus/share_plus.dart';
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../models/image_codec_support.dart';
|
||||
import '../models/translation_support.dart';
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/backup_service.dart';
|
||||
import '../services/image_codec_service.dart';
|
||||
import '../services/translation_service.dart';
|
||||
import '../services/message_filter/message_filter_service.dart';
|
||||
import '../utils/platform_info.dart';
|
||||
import '../utils/share_origin.dart';
|
||||
@@ -429,6 +433,8 @@ class _BackupRestoreScreenState extends State<BackupRestoreScreen> {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final appSettingsService = context.read<AppSettingsService>();
|
||||
final messageFilterService = context.read<MessageFilterService>();
|
||||
final translationService = context.read<TranslationService>();
|
||||
final imageCodecService = context.read<ImageCodecService>();
|
||||
final needsKeyConfirmation = _selectedItems.contains(BackupItem.privateKey);
|
||||
if (needsKeyConfirmation && !await _confirmIdentityReplacement()) return;
|
||||
setState(() => _busy = true);
|
||||
@@ -447,6 +453,13 @@ class _BackupRestoreScreenState extends State<BackupRestoreScreen> {
|
||||
item == BackupItem.stadiaMapKey,
|
||||
)) {
|
||||
await appSettingsService.loadSettings();
|
||||
if (_selectedItems.contains(BackupItem.appSettings)) {
|
||||
await _offerMissingModels(
|
||||
appSettingsService,
|
||||
translationService,
|
||||
imageCodecService,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (_selectedItems.contains(BackupItem.channelFilters)) {
|
||||
await messageFilterService.load();
|
||||
@@ -476,6 +489,312 @@ class _BackupRestoreScreenState extends State<BackupRestoreScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _offerMissingModels(
|
||||
AppSettingsService appSettingsService,
|
||||
TranslationService translationService,
|
||||
ImageCodecService imageCodecService,
|
||||
) async {
|
||||
if (PlatformInfo.isWeb) return;
|
||||
final settings = appSettingsService.settings;
|
||||
final translationId = settings.translationSelectedModelId;
|
||||
final imageCodecId = settings.imageCodecSelectedModelId;
|
||||
|
||||
TranslationModelRecord? translationModel;
|
||||
for (final model in settings.translationDownloadedModels) {
|
||||
if (model.id == translationId) {
|
||||
translationModel = model;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (final model in translationPresetModels) {
|
||||
if (model.id == translationId) {
|
||||
translationModel ??= model;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (translationModel == null &&
|
||||
translationId != null &&
|
||||
settings.translationModelSourceUrl != null) {
|
||||
final uri = Uri.tryParse(settings.translationModelSourceUrl!);
|
||||
final pathSegments = uri?.pathSegments ?? const <String>[];
|
||||
final fileName = pathSegments.isEmpty ? null : pathSegments.last;
|
||||
translationModel = TranslationModelRecord(
|
||||
id: translationId,
|
||||
name: fileName?.isNotEmpty == true ? fileName! : translationId,
|
||||
sourceUrl: settings.translationModelSourceUrl!,
|
||||
localPath: '',
|
||||
downloadedAt: DateTime.fromMillisecondsSinceEpoch(0),
|
||||
fileSizeBytes: 0,
|
||||
);
|
||||
}
|
||||
|
||||
ImageCodecModelRecord? imageCodecModel;
|
||||
for (final model in settings.imageCodecDownloadedModels) {
|
||||
if (model.id == imageCodecId) {
|
||||
imageCodecModel = model;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImageCodecModelSpec? imageCodecSpec;
|
||||
for (final spec in imageCodecPresetModels) {
|
||||
if (spec.id == imageCodecId) {
|
||||
imageCodecSpec = spec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (imageCodecModel == null && imageCodecSpec != null) {
|
||||
final graph = imageCodecSpec.graph;
|
||||
imageCodecModel = ImageCodecModelRecord(
|
||||
id: imageCodecSpec.id,
|
||||
name: graph.fileName,
|
||||
sourceUrl: graph.sourceUrl,
|
||||
localPath: '',
|
||||
downloadedAt: DateTime.fromMillisecondsSinceEpoch(0),
|
||||
fileSizeBytes: imageCodecSpec.totalSizeBytes,
|
||||
assetFileNames: [
|
||||
for (final asset in imageCodecSpec.assets) asset.fileName,
|
||||
],
|
||||
bundleVersion: kImageCodecBundleVersion,
|
||||
);
|
||||
} else if (imageCodecModel == null &&
|
||||
imageCodecId != null &&
|
||||
settings.imageCodecModelSourceUrl != null) {
|
||||
final uri = Uri.tryParse(settings.imageCodecModelSourceUrl!);
|
||||
final pathSegments = uri?.pathSegments ?? const <String>[];
|
||||
final fileName = pathSegments.isEmpty ? null : pathSegments.last;
|
||||
imageCodecModel = ImageCodecModelRecord(
|
||||
id: imageCodecId,
|
||||
name: fileName?.isNotEmpty == true ? fileName! : imageCodecId,
|
||||
sourceUrl: settings.imageCodecModelSourceUrl!,
|
||||
localPath: '',
|
||||
downloadedAt: DateTime.fromMillisecondsSinceEpoch(0),
|
||||
fileSizeBytes: 0,
|
||||
);
|
||||
}
|
||||
|
||||
await translationService.refreshDownloadedModels(clearMissing: true);
|
||||
await imageCodecService.refreshDownloadedModels(clearMissing: true);
|
||||
|
||||
final translationRequest = translationModel;
|
||||
final translationMissing =
|
||||
translationRequest != null &&
|
||||
!translationService.availableModels.any(
|
||||
(model) =>
|
||||
model.id == translationRequest.id ||
|
||||
model.name == translationRequest.name,
|
||||
);
|
||||
ImageCodecModelRecord? installedCodec;
|
||||
if (imageCodecModel != null) {
|
||||
for (final model in imageCodecService.availableModels) {
|
||||
if (model.id == imageCodecModel.id ||
|
||||
model.name == imageCodecModel.name) {
|
||||
installedCodec = model;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final codecRequest = imageCodecModel;
|
||||
final installedCodecForCheck = installedCodec;
|
||||
final imageCodecMissing =
|
||||
codecRequest != null &&
|
||||
(imageCodecSpec != null
|
||||
? !imageCodecSpec.hasCompleteInstalledRecord(
|
||||
imageCodecService.availableModels,
|
||||
)
|
||||
: installedCodecForCheck == null);
|
||||
if (!translationMissing && !imageCodecMissing) return;
|
||||
if (!mounted) return;
|
||||
|
||||
await _showModelDownloadDialog(
|
||||
translationModel: translationMissing ? translationRequest : null,
|
||||
imageCodecModel: imageCodecMissing ? codecRequest : null,
|
||||
imageCodecSpec: imageCodecMissing ? imageCodecSpec : null,
|
||||
translationService: translationService,
|
||||
imageCodecService: imageCodecService,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showModelDownloadDialog({
|
||||
required TranslationModelRecord? translationModel,
|
||||
required ImageCodecModelRecord? imageCodecModel,
|
||||
required ImageCodecModelSpec? imageCodecSpec,
|
||||
required TranslationService translationService,
|
||||
required ImageCodecService imageCodecService,
|
||||
}) async {
|
||||
final l10n = context.l10n;
|
||||
final modelNames = [
|
||||
if (translationModel != null)
|
||||
translationModelFriendlyName(translationModel),
|
||||
if (imageCodecModel != null)
|
||||
imageCodecSpec?.label ?? imageCodecModel.name,
|
||||
];
|
||||
var starting = false;
|
||||
var cancelRequested = false;
|
||||
var translationDone = translationModel == null;
|
||||
var imageCodecDone = imageCodecModel == null;
|
||||
String? currentModel;
|
||||
String? downloadError;
|
||||
final servicesListenable = Listenable.merge([
|
||||
translationService,
|
||||
imageCodecService,
|
||||
]);
|
||||
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AnimatedBuilder(
|
||||
animation: servicesListenable,
|
||||
builder: (context, _) {
|
||||
final isDownloading =
|
||||
starting ||
|
||||
translationService.isDownloading ||
|
||||
imageCodecService.isDownloading;
|
||||
final currentProgress = currentModel == translationModel?.name
|
||||
? translationService.downloadProgress
|
||||
: currentModel == imageCodecModel?.name
|
||||
? imageCodecService.downloadProgress
|
||||
: null;
|
||||
final currentFile = currentModel == translationModel?.name
|
||||
? translationService.downloadFileName
|
||||
: currentModel == imageCodecModel?.name
|
||||
? imageCodecService.downloadFileName
|
||||
: null;
|
||||
|
||||
void requestDownloadCancel() {
|
||||
cancelRequested = true;
|
||||
translationService.cancelDownload();
|
||||
imageCodecService.cancelDownload();
|
||||
}
|
||||
|
||||
return PopScope<void>(
|
||||
canPop: !isDownloading,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop && isDownloading) requestDownloadCancel();
|
||||
},
|
||||
child: AlertDialog(
|
||||
title: Text(l10n.backupRestore_missingModelsTitle),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.backupRestore_missingModelsMessage(
|
||||
modelNames.join('\n'),
|
||||
),
|
||||
),
|
||||
if (isDownloading) ...[
|
||||
const SizedBox(height: 16),
|
||||
Text(currentFile ?? currentModel ?? ''),
|
||||
const SizedBox(height: 8),
|
||||
LinearProgressIndicator(value: currentProgress),
|
||||
],
|
||||
if (downloadError != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
l10n.backupRestore_failed(downloadError!),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (isDownloading) {
|
||||
requestDownloadCancel();
|
||||
} else {
|
||||
Navigator.pop(dialogContext);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
isDownloading
|
||||
? l10n.backupRestore_cancelDownload
|
||||
: l10n.common_cancel,
|
||||
),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: isDownloading
|
||||
? null
|
||||
: () async {
|
||||
setDialogState(() {
|
||||
starting = true;
|
||||
currentModel = translationDone
|
||||
? imageCodecModel?.name
|
||||
: translationModel?.name;
|
||||
downloadError = null;
|
||||
});
|
||||
try {
|
||||
if (!translationDone) {
|
||||
final model = translationModel!;
|
||||
if (model.sourceUrl.isEmpty) {
|
||||
throw StateError(
|
||||
'No download address is available for ${model.name}',
|
||||
);
|
||||
}
|
||||
await translationService.downloadModel(
|
||||
sourceUrl: model.sourceUrl,
|
||||
fileName: model.name,
|
||||
id: model.id,
|
||||
);
|
||||
translationDone = true;
|
||||
setDialogState(() {
|
||||
currentModel = imageCodecModel?.name;
|
||||
});
|
||||
}
|
||||
if (!imageCodecDone) {
|
||||
final model = imageCodecModel!;
|
||||
final spec = imageCodecSpec;
|
||||
if (spec != null) {
|
||||
await imageCodecService.downloadPresetModel(
|
||||
spec,
|
||||
);
|
||||
} else if (model.sourceUrl.isNotEmpty) {
|
||||
await imageCodecService.downloadModel(
|
||||
sourceUrl: model.sourceUrl,
|
||||
fileName: model.name,
|
||||
id: model.id,
|
||||
);
|
||||
} else {
|
||||
throw StateError(
|
||||
'No download address is available for ${model.name}',
|
||||
);
|
||||
}
|
||||
imageCodecDone = true;
|
||||
}
|
||||
if (dialogContext.mounted) {
|
||||
Navigator.pop(dialogContext);
|
||||
}
|
||||
} catch (error) {
|
||||
if (dialogContext.mounted) {
|
||||
if (cancelRequested) {
|
||||
Navigator.pop(dialogContext);
|
||||
} else {
|
||||
setDialogState(() {
|
||||
starting = false;
|
||||
downloadError = error.toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
isDownloading
|
||||
? l10n.backupRestore_downloading
|
||||
: l10n.backupRestore_downloadModels,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _confirmIdentityReplacement() async {
|
||||
final l10n = context.l10n;
|
||||
return await showDialog<bool>(
|
||||
|
||||
@@ -480,6 +480,10 @@ class BackupService {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!importingIdentity &&
|
||||
selectedItems.contains(BackupItem.discoveredContacts)) {
|
||||
await connector.reloadDiscoveredContacts();
|
||||
}
|
||||
if (replaceContacts) {
|
||||
await _restoreRadioContacts(connector, destinationPublicKey);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user