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:
zjs81 committed 2026-10-24 21:03:39 -07:00
1 parent 1e786b24ba
commit f2a27f0f71
28 files changed
+352 -10

No files matched your search

+27 -2
View File
@@ -1758,6 +1758,16 @@ class _ContactsScreenState extends State<ContactsScreen>
Text(
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(
contentPadding: EdgeInsets.zero,
controlAffinity: ListTileControlAffinity.leading,
@@ -1774,9 +1784,24 @@ class _ContactsScreenState extends State<ContactsScreen>
child: Text(context.l10n.common_cancel),
),
TextButton(
onPressed: () {
onPressed: () async {
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(
context.l10n.contacts_remove,
+9 -1
View File
@@ -316,7 +316,15 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
content: Text(context.l10n.discoveredContacts_contactAdded),
action: SnackBarAction(
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 (_) {