Wait for the radio before removing a contact, and explain re-adds
removeContact now waits for the radio's reply and only drops the contact locally when the radio confirms (or reports it doesn't have it), so a lost command no longer leaves a contact that the next sync restores. Failures are shown to the user. The delete dialog warns when the radio auto-adds that contact type, since the contact returns on its next advert.
This commit is contained in:
1 parent
1e786b24ba
commit
f2a27f0f71
28 files changed
+352
-10
No files matched your search
@@ -80,7 +80,7 @@ Groups are stored per radio identity (scoped by public key).
|
|||||||
| Add/Remove Favorite | All types | Toggles the favorite flag |
|
| Add/Remove Favorite | All types | Toggles the favorite flag |
|
||||||
| Share Contact | All types | Requests advert from device → copies `meshcore://<hex>` URI to clipboard |
|
| Share Contact | All types | Requests advert from device → copies `meshcore://<hex>` URI to clipboard |
|
||||||
| Share Contact Zero-Hop | All types | Broadcasts the contact's advertisement one hop |
|
| Share Contact Zero-Hop | All types | Broadcasts the contact's advertisement one hop |
|
||||||
| Delete Contact | All types | Confirmation dialog → removes from device and clears messages |
|
| Delete Contact | All types | Confirmation dialog → removes from device and clears messages. If auto-add is on for that type, the radio adds it back the next time it advertises; the dialog warns about this |
|
||||||
|
|
||||||
## App Bar Menus
|
## App Bar Menus
|
||||||
|
|
||||||
|
|||||||
@@ -667,6 +667,16 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
bool? get autoAddSensors => _autoAddSensors;
|
bool? get autoAddSensors => _autoAddSensors;
|
||||||
bool? get autoAddOverwriteOldest => _overwriteOldest;
|
bool? get autoAddOverwriteOldest => _overwriteOldest;
|
||||||
|
|
||||||
|
/// Whether the radio stores adverts of [type] by itself, so a removed
|
||||||
|
/// contact of that type returns the next time it advertises.
|
||||||
|
bool autoAddsContactType(int type) => switch (type) {
|
||||||
|
advTypeChat => _autoAddUsers,
|
||||||
|
advTypeRepeater => _autoAddRepeaters,
|
||||||
|
advTypeRoom => _autoAddRoomServers,
|
||||||
|
advTypeSensor => _autoAddSensors,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
/// autoadd_max_hops from GET_AUTOADD_CONFIG (0 = no limit), null when the
|
/// autoadd_max_hops from GET_AUTOADD_CONFIG (0 = no limit), null when the
|
||||||
/// firmware did not report it (pre-v1.13).
|
/// firmware did not report it (pre-v1.13).
|
||||||
int? get autoAddMaxHops => _autoAddMaxHops;
|
int? get autoAddMaxHops => _autoAddMaxHops;
|
||||||
@@ -5034,13 +5044,26 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
}) async {
|
}) async {
|
||||||
if (!isConnected) return;
|
if (!isConnected) return;
|
||||||
|
|
||||||
|
// Only drop the contact locally once the radio confirms; otherwise the
|
||||||
|
// next contact sync restores it. ERR means the radio does not have it.
|
||||||
|
try {
|
||||||
|
await sendFrame(
|
||||||
|
buildRemoveContactFrame(contact.publicKey),
|
||||||
|
waitForGenericAck: true,
|
||||||
|
);
|
||||||
|
} on FirmwareCommandException catch (e) {
|
||||||
|
_appDebugLogService?.warn(
|
||||||
|
'Radio has no contact ${contact.publicKeyHex.substring(0, 8)} '
|
||||||
|
'(error ${e.errCode}); removing it locally',
|
||||||
|
tag: 'Connector',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_handleDiscovery(
|
_handleDiscovery(
|
||||||
contact,
|
contact,
|
||||||
contact.rawPacket ?? Uint8List(0),
|
contact.rawPacket ?? Uint8List(0),
|
||||||
noNotify: true,
|
noNotify: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
await sendFrame(buildRemoveContactFrame(contact.publicKey));
|
|
||||||
_contactsStorageFull = false;
|
_contactsStorageFull = false;
|
||||||
_contacts.removeWhere((c) => c.publicKeyHex == contact.publicKeyHex);
|
_contacts.removeWhere((c) => c.publicKeyHex == contact.publicKeyHex);
|
||||||
_knownContactKeys.remove(contact.publicKeyHex);
|
_knownContactKeys.remove(contact.publicKeyHex);
|
||||||
|
|||||||
@@ -5,6 +5,16 @@ import 'package:flutter/foundation.dart';
|
|||||||
import '../services/image_chunk_transport.dart' show cmdSendChannelData;
|
import '../services/image_chunk_transport.dart' show cmdSendChannelData;
|
||||||
import 'meshcore_protocol.dart';
|
import 'meshcore_protocol.dart';
|
||||||
|
|
||||||
|
/// RESP_CODE_ERR received for a command that was waiting for its reply.
|
||||||
|
class FirmwareCommandException implements Exception {
|
||||||
|
final int errCode;
|
||||||
|
|
||||||
|
const FirmwareCommandException(this.errCode);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => 'Exception: Command failed with error code $errCode';
|
||||||
|
}
|
||||||
|
|
||||||
/// A command waiting for its reply from the companion firmware.
|
/// A command waiting for its reply from the companion firmware.
|
||||||
class PendingCommandReply {
|
class PendingCommandReply {
|
||||||
final int commandCode;
|
final int commandCode;
|
||||||
@@ -203,9 +213,7 @@ class PendingCommandReplies {
|
|||||||
if (_queue.isEmpty) return null;
|
if (_queue.isEmpty) return null;
|
||||||
final pending = _queue.removeAt(0);
|
final pending = _queue.removeAt(0);
|
||||||
if (pending.isTombstone) return null;
|
if (pending.isTombstone) return null;
|
||||||
pending.completer?.completeError(
|
pending.completer?.completeError(FirmwareCommandException(errCode));
|
||||||
Exception('Command failed with error code $errCode'),
|
|
||||||
);
|
|
||||||
return pending;
|
return pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -608,6 +608,8 @@
|
|||||||
},
|
},
|
||||||
"contacts_keepChatHistory": "Keep chat history",
|
"contacts_keepChatHistory": "Keep chat history",
|
||||||
"contacts_remove": "Remove",
|
"contacts_remove": "Remove",
|
||||||
|
"contacts_removeAutoAddNote": "Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.",
|
||||||
|
"contacts_removeFailed": "The radio did not confirm the removal. The contact was not removed.",
|
||||||
"contacts_discoveredNearby": "Discovered nearby ({count})",
|
"contacts_discoveredNearby": "Discovered nearby ({count})",
|
||||||
"@contacts_discoveredNearby": {
|
"@contacts_discoveredNearby": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
|
|||||||
@@ -2314,6 +2314,18 @@ abstract class AppLocalizations {
|
|||||||
/// **'Remove'**
|
/// **'Remove'**
|
||||||
String get contacts_remove;
|
String get contacts_remove;
|
||||||
|
|
||||||
|
/// No description provided for @contacts_removeAutoAddNote.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.'**
|
||||||
|
String get contacts_removeAutoAddNote;
|
||||||
|
|
||||||
|
/// No description provided for @contacts_removeFailed.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'The radio did not confirm the removal. The contact was not removed.'**
|
||||||
|
String get contacts_removeFailed;
|
||||||
|
|
||||||
/// No description provided for @contacts_discoveredNearby.
|
/// No description provided for @contacts_discoveredNearby.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -1290,6 +1290,14 @@ class AppLocalizationsBg extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Премахни';
|
String get contacts_remove => 'Премахни';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Открити наблизо ($count)';
|
return 'Открити наблизо ($count)';
|
||||||
|
|||||||
@@ -1285,6 +1285,14 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Entfernen';
|
String get contacts_remove => 'Entfernen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'In der Nähe entdeckt ($count)';
|
return 'In der Nähe entdeckt ($count)';
|
||||||
|
|||||||
@@ -1267,6 +1267,14 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Remove';
|
String get contacts_remove => 'Remove';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Discovered nearby ($count)';
|
return 'Discovered nearby ($count)';
|
||||||
|
|||||||
@@ -1282,6 +1282,14 @@ class AppLocalizationsEs extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Eliminar';
|
String get contacts_remove => 'Eliminar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Descubiertos cercanos ($count)';
|
return 'Descubiertos cercanos ($count)';
|
||||||
|
|||||||
@@ -1288,6 +1288,14 @@ class AppLocalizationsFr extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Supprimer';
|
String get contacts_remove => 'Supprimer';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Découverts à proximité ($count)';
|
return 'Découverts à proximité ($count)';
|
||||||
|
|||||||
@@ -1278,6 +1278,14 @@ class AppLocalizationsHu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Eltávolítás';
|
String get contacts_remove => 'Eltávolítás';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Közelben felfedezve ($count)';
|
return 'Közelben felfedezve ($count)';
|
||||||
|
|||||||
@@ -1287,6 +1287,14 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Rimuovi';
|
String get contacts_remove => 'Rimuovi';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Scoperti nelle vicinanze ($count)';
|
return 'Scoperti nelle vicinanze ($count)';
|
||||||
|
|||||||
@@ -1215,6 +1215,14 @@ class AppLocalizationsJa extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => '削除';
|
String get contacts_remove => '削除';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return '近くで発見された連絡先($count)';
|
return '近くで発見された連絡先($count)';
|
||||||
|
|||||||
@@ -1220,6 +1220,14 @@ class AppLocalizationsKo extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => '제거';
|
String get contacts_remove => '제거';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return '주변에서 발견됨($count)';
|
return '주변에서 발견됨($count)';
|
||||||
|
|||||||
@@ -1277,6 +1277,14 @@ class AppLocalizationsNl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Verwijderen';
|
String get contacts_remove => 'Verwijderen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'In de buurt ontdekt ($count)';
|
return 'In de buurt ontdekt ($count)';
|
||||||
|
|||||||
@@ -1301,6 +1301,14 @@ class AppLocalizationsPl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Usuń';
|
String get contacts_remove => 'Usuń';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Odkryte w pobliżu ($count)';
|
return 'Odkryte w pobliżu ($count)';
|
||||||
|
|||||||
@@ -1286,6 +1286,14 @@ class AppLocalizationsPt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Remover';
|
String get contacts_remove => 'Remover';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Descobertos nas proximidades ($count)';
|
return 'Descobertos nas proximidades ($count)';
|
||||||
|
|||||||
@@ -1290,6 +1290,14 @@ class AppLocalizationsRu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Убрать';
|
String get contacts_remove => 'Убрать';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Обнаружены поблизости ($count)';
|
return 'Обнаружены поблизости ($count)';
|
||||||
|
|||||||
@@ -1277,6 +1277,14 @@ class AppLocalizationsSk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Odstrániť';
|
String get contacts_remove => 'Odstrániť';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Objavené v blízkosti ($count)';
|
return 'Objavené v blízkosti ($count)';
|
||||||
|
|||||||
@@ -1277,6 +1277,14 @@ class AppLocalizationsSl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Odstrani';
|
String get contacts_remove => 'Odstrani';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Odkriti v bližini ($count)';
|
return 'Odkriti v bližini ($count)';
|
||||||
|
|||||||
@@ -1267,6 +1267,14 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Ta bort';
|
String get contacts_remove => 'Ta bort';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Upptäckt i närheten ($count)';
|
return 'Upptäckt i närheten ($count)';
|
||||||
|
|||||||
@@ -1281,6 +1281,14 @@ class AppLocalizationsUk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => 'Прибрати';
|
String get contacts_remove => 'Прибрати';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return 'Виявлені поблизу ($count)';
|
return 'Виявлені поблизу ($count)';
|
||||||
|
|||||||
@@ -1197,6 +1197,14 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get contacts_remove => '移除';
|
String get contacts_remove => '移除';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeAutoAddNote =>
|
||||||
|
'Your radio auto-adds this contact type, so it will come back the next time it advertises. Turn off auto-add in Contacts settings to keep it removed.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get contacts_removeFailed =>
|
||||||
|
'The radio did not confirm the removal. The contact was not removed.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String contacts_discoveredNearby(int count) {
|
String contacts_discoveredNearby(int count) {
|
||||||
return '附近发现的($count)';
|
return '附近发现的($count)';
|
||||||
|
|||||||
@@ -1758,6 +1758,16 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
Text(
|
Text(
|
||||||
context.l10n.contacts_removeFromContactsConfirm(contact.name),
|
context.l10n.contacts_removeFromContactsConfirm(contact.name),
|
||||||
),
|
),
|
||||||
|
if (connector.autoAddsContactType(contact.type)) ...[
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
context.l10n.contacts_removeAutoAddNote,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(dialogContext).colorScheme.error,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
@@ -1774,9 +1784,24 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
child: Text(context.l10n.common_cancel),
|
child: Text(context.l10n.common_cancel),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.pop(dialogContext);
|
Navigator.pop(dialogContext);
|
||||||
connector.removeContact(contact, keepMessages: keepHistory);
|
try {
|
||||||
|
await connector.removeContact(
|
||||||
|
contact,
|
||||||
|
keepMessages: keepHistory,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
appLogger.warn(
|
||||||
|
'Remove contact failed: $e',
|
||||||
|
tag: 'ContactsScreen',
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showDismissibleSnackBar(
|
||||||
|
context,
|
||||||
|
content: Text(context.l10n.contacts_removeFailed),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
context.l10n.contacts_remove,
|
context.l10n.contacts_remove,
|
||||||
|
|||||||
@@ -316,7 +316,15 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
|||||||
content: Text(context.l10n.discoveredContacts_contactAdded),
|
content: Text(context.l10n.discoveredContacts_contactAdded),
|
||||||
action: SnackBarAction(
|
action: SnackBarAction(
|
||||||
label: context.l10n.common_undo,
|
label: context.l10n.common_undo,
|
||||||
onPressed: () => connector.removeContact(contact),
|
onPressed: () => unawaited(
|
||||||
|
connector.removeContact(contact).catchError((Object _) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showDismissibleSnackBar(
|
||||||
|
context,
|
||||||
|
content: Text(context.l10n.contacts_removeFailed),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|||||||
@@ -65,7 +65,12 @@ void main() {
|
|||||||
waitForReply: true,
|
waitForReply: true,
|
||||||
);
|
);
|
||||||
queue.takeErr(6);
|
queue.takeErr(6);
|
||||||
await expectLater(pending!.completer!.future, throwsException);
|
await expectLater(
|
||||||
|
pending!.completer!.future,
|
||||||
|
throwsA(
|
||||||
|
isA<FirmwareCommandException>().having((e) => e.errCode, 'errCode', 6),
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
group('timed-out entries', () {
|
group('timed-out entries', () {
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||||
|
import 'package:meshcore_open/connector/meshcore_protocol.dart';
|
||||||
|
import 'package:meshcore_open/review_mode/review_radio.dart';
|
||||||
|
import 'package:meshcore_open/services/message_retry_service.dart';
|
||||||
|
import 'package:meshcore_open/services/path_history_service.dart';
|
||||||
|
import 'package:meshcore_open/services/storage_service.dart';
|
||||||
|
import 'package:meshcore_open/storage/contact_store.dart';
|
||||||
|
import 'package:meshcore_open/storage/prefs_manager.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
Future<void> _waitFor(bool Function() condition, {int seconds = 8}) async {
|
||||||
|
final end = DateTime.now().add(Duration(seconds: seconds));
|
||||||
|
while (!condition()) {
|
||||||
|
if (DateTime.now().isAfter(end)) fail('Timed out waiting for condition');
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 25));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
PrefsManager.reset();
|
||||||
|
await PrefsManager.initialize();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('removed contact stays gone from the radio, list and store', () async {
|
||||||
|
final connector = MeshCoreConnector();
|
||||||
|
addTearDown(connector.dispose);
|
||||||
|
final retryService = MessageRetryService();
|
||||||
|
addTearDown(retryService.dispose);
|
||||||
|
connector.initialize(
|
||||||
|
retryService: retryService,
|
||||||
|
pathHistoryService: PathHistoryService(StorageService()),
|
||||||
|
);
|
||||||
|
connector.reviewRadioFactoryForTest = () =>
|
||||||
|
ReviewRadio(scheduledMessageInterval: const Duration(hours: 1));
|
||||||
|
|
||||||
|
await connector.connectReview();
|
||||||
|
await _waitFor(
|
||||||
|
() => connector.hasLoadedContacts && connector.contacts.length >= 6,
|
||||||
|
);
|
||||||
|
final contact = connector.contacts.firstWhere((c) => c.name == 'Maya');
|
||||||
|
|
||||||
|
await connector.removeContact(contact);
|
||||||
|
|
||||||
|
bool listed() =>
|
||||||
|
connector.contacts.any((c) => c.publicKeyHex == contact.publicKeyHex);
|
||||||
|
expect(listed(), isFalse);
|
||||||
|
expect(
|
||||||
|
connector.discoveredContacts
|
||||||
|
.firstWhere((c) => c.publicKeyHex == contact.publicKeyHex)
|
||||||
|
.isActive,
|
||||||
|
isFalse,
|
||||||
|
);
|
||||||
|
|
||||||
|
// A full resync from the radio must not bring it back.
|
||||||
|
await connector.getContacts();
|
||||||
|
await _waitFor(() => connector.hasLoadedContacts);
|
||||||
|
expect(connector.contacts, isNotEmpty);
|
||||||
|
expect(listed(), isFalse);
|
||||||
|
|
||||||
|
final store = ContactStore()..setPublicKeyHex = connector.selfPublicKeyHex;
|
||||||
|
final saved = await store.loadContacts();
|
||||||
|
expect(saved.any((c) => c.publicKeyHex == contact.publicKeyHex), isFalse);
|
||||||
|
|
||||||
|
await connector.disconnect(manual: true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('auto-add config reports which contact types come back', () {
|
||||||
|
final connector = MeshCoreConnector();
|
||||||
|
addTearDown(connector.dispose);
|
||||||
|
connector.handleFrameForTest([respCodeAutoAddConfig, autoAddRepeaterFlag]);
|
||||||
|
|
||||||
|
expect(connector.autoAddsContactType(advTypeRepeater), isTrue);
|
||||||
|
expect(connector.autoAddsContactType(advTypeChat), isFalse);
|
||||||
|
expect(connector.autoAddsContactType(advTypeRoom), isFalse);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"bg": [
|
"bg": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -20,6 +22,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"de": [
|
"de": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -40,6 +44,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"es": [
|
"es": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -60,6 +66,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"fr": [
|
"fr": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -80,6 +88,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"hu": [
|
"hu": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -100,6 +110,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"it": [
|
"it": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -120,6 +132,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"ja": [
|
"ja": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -140,6 +154,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"ko": [
|
"ko": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -160,6 +176,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"nl": [
|
"nl": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -180,6 +198,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"pl": [
|
"pl": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -200,6 +220,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"pt": [
|
"pt": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -220,6 +242,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"ru": [
|
"ru": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -240,6 +264,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"sk": [
|
"sk": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -260,6 +286,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"sl": [
|
"sl": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -280,6 +308,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"sv": [
|
"sv": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -300,6 +330,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"uk": [
|
"uk": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
@@ -320,6 +352,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"zh": [
|
"zh": [
|
||||||
|
"contacts_removeAutoAddNote",
|
||||||
|
"contacts_removeFailed",
|
||||||
"map_pathTraceAddMoreHint",
|
"map_pathTraceAddMoreHint",
|
||||||
"map_pathTraceModeRoundTrip",
|
"map_pathTraceModeRoundTrip",
|
||||||
"map_pathTraceModeRoundTripHint",
|
"map_pathTraceModeRoundTripHint",
|
||||||
|
|||||||
Reference in new issue
Block a user