Conversation
There was a problem hiding this comment.
Pull request overview
Adds import/export support for discovered contacts so users can persist/share them as a JSON file, including desktop save/open flows and localized UI strings.
Changes:
- Add JSON export/import actions to the Discovery screen (desktop uses
file_selector, mobile/web uses sharing). - Extend discovered-contacts persistence to be per-node scoped (SharedPreferences key scoping + legacy migration) and add merge logic for imported contacts.
- Add new localization strings for import/export UI and register the
file_selectorplugin for desktop platforms.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| windows/flutter/generated_plugins.cmake | Adds Windows desktop plugin entry for file_selector_windows. |
| windows/flutter/generated_plugin_registrant.cc | Registers FileSelectorWindows plugin. |
| pubspec.yaml | Adds file_selector dependency. |
| macos/Flutter/GeneratedPluginRegistrant.swift | Registers file_selector_macos (+ path_provider_foundation plugin registration). |
| linux/flutter/generated_plugins.cmake | Adds Linux desktop plugin entry for file_selector_linux. |
| linux/flutter/generated_plugin_registrant.cc | Registers file_selector_linux plugin. |
| lib/storage/contact_discovery_store.dart | Adds per-node scoping/migration + JSON encode/decode and import/export merge helpers. |
| lib/screens/discovery_screen.dart | Adds popup actions and file/share-based import/export implementation. |
| lib/connector/meshcore_connector.dart | Exposes exportDiscoveredContactsJson / importDiscoveredContactsJson and wires scoping into store initialization. |
| lib/l10n/app_localizations.dart | Adds localization API for discovered contacts import/export strings. |
| lib/l10n/app_en.arb | Adds English strings for discovered contacts import/export. |
| lib/l10n/app_de.arb | Adds German strings for discovered contacts import/export. |
| lib/l10n/app_es.arb | Adds Spanish strings for discovered contacts import/export. |
| lib/l10n/app_fr.arb | Adds French strings for discovered contacts import/export. |
| lib/l10n/app_it.arb | Adds Italian strings for discovered contacts import/export. |
| lib/l10n/app_nl.arb | Adds Dutch strings for discovered contacts import/export. |
| lib/l10n/app_pl.arb | Adds Polish strings for discovered contacts import/export. |
| lib/l10n/app_pt.arb | Adds Portuguese strings for discovered contacts import/export. |
| lib/l10n/app_ru.arb | Adds Russian strings for discovered contacts import/export. |
| lib/l10n/app_sk.arb | Adds Slovak strings for discovered contacts import/export. |
| lib/l10n/app_sl.arb | Adds Slovenian strings for discovered contacts import/export. |
| lib/l10n/app_sv.arb | Adds Swedish strings for discovered contacts import/export. |
| lib/l10n/app_uk.arb | Adds Ukrainian strings for discovered contacts import/export. |
| lib/l10n/app_zh.arb | Adds Chinese strings for discovered contacts import/export. |
| lib/l10n/app_localizations_en.dart | Adds generated English getters/messages for new strings. |
| lib/l10n/app_localizations_de.dart | Adds generated German getters/messages for new strings. |
| lib/l10n/app_localizations_es.dart | Adds generated Spanish getters/messages for new strings. |
| lib/l10n/app_localizations_fr.dart | Adds generated French getters/messages for new strings. |
| lib/l10n/app_localizations_it.dart | Adds generated Italian getters/messages for new strings. |
| lib/l10n/app_localizations_nl.dart | Adds generated Dutch getters/messages for new strings. |
| lib/l10n/app_localizations_pl.dart | Adds generated Polish getters/messages for new strings. |
| lib/l10n/app_localizations_pt.dart | Adds generated Portuguese getters/messages for new strings. |
| lib/l10n/app_localizations_ru.dart | Adds generated Russian getters/messages for new strings. |
| lib/l10n/app_localizations_sk.dart | Adds generated Slovak getters/messages for new strings. |
| lib/l10n/app_localizations_sl.dart | Adds generated Slovenian getters/messages for new strings. |
| lib/l10n/app_localizations_sv.dart | Adds generated Swedish getters/messages for new strings. |
| lib/l10n/app_localizations_uk.dart | Adds generated Ukrainian getters/messages for new strings. |
| lib/l10n/app_localizations_zh.dart | Adds generated Chinese getters/messages for new strings. |
| lib/l10n/app_localizations_bg.dart | Adds generated Bulgarian getters/messages for new strings. |
| lib/l10n/app_bg.arb | Adds Bulgarian strings for discovered contacts import/export. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| onSelected: (value) { | ||
| switch (value) { | ||
| case 'export': | ||
| _exportDiscoveredContacts(context, connector); | ||
| break; |
| Future<void> saveContacts(List<Contact> contacts) async { | ||
| final prefs = PrefsManager.instance; | ||
| await prefs.setString(keyFor, encodeContacts(contacts)); | ||
| } |
lib/screens/discovery_screen.dart
Outdated
| final importedCount = await connector.importDiscoveredContactsJson(json); | ||
| if (importedCount == 0) { | ||
| if (!mounted) return; | ||
| messenger.showSnackBar( | ||
| SnackBar(content: Text(l10n.discoveredContacts_importNoContacts)), |
| String publicKeyHex = ''; | ||
| set setPublicKeyHex(String value) => | ||
| publicKeyHex = value.length > 10 ? value.substring(0, 10) : ''; | ||
|
|
||
| String get keyFor => '$_keyPrefix$publicKeyHex'; |
| Future<List<Contact>> loadContacts() async { | ||
| final prefs = PrefsManager.instance; | ||
| var jsonStr = prefs.getString(keyFor); | ||
| if ((jsonStr == null || jsonStr.isEmpty) && publicKeyHex.isNotEmpty) { | ||
| // One-time migration from legacy unscoped key. |
…vered contacts), simplified calculations for prefix match
|
I let my agent change the detection from overlapping prefixes change from an O(n^2) to O(n) approach and also added this and the guessed location into app-settings to allow disabling it before going to map. With the change of the prefixes the map could handle the 1200+ contacts. PS: I do not know why dart says LatLang is an unused import, since it clealy does not build without." |
Allows to import and export discovered Contacts
I hope it is easier to manage if i split up my changes.