From 64d0019e6e50fe20324336e77a323a647aaf8db7 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sun, 21 Apr 2024 22:16:22 -0400 Subject: [PATCH] watchvalue fixes --- assets/i18n/en.json | 1 + .../cubits/single_contact_messages_cubit.dart | 10 ++++------ .../views/invitation_dialog.dart | 9 +++++++-- .../dht_support/src/dht_record/dht_record.dart | 16 ++++++++-------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 2a1e4ac..f074031 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -96,6 +96,7 @@ "failed_to_accept": "Failed to accept contact invitation", "failed_to_reject": "Failed to reject contact invitation", "invalid_invitation": "Invalid invitation", + "try_again_online": "Invitation could not be reached, try again when online", "protected_with_pin": "Contact invitation is protected with a PIN", "protected_with_password": "Contact invitation is protected with a password", "invalid_pin": "Invalid PIN", diff --git a/lib/chat/cubits/single_contact_messages_cubit.dart b/lib/chat/cubits/single_contact_messages_cubit.dart index 72a6a90..41c872d 100644 --- a/lib/chat/cubits/single_contact_messages_cubit.dart +++ b/lib/chat/cubits/single_contact_messages_cubit.dart @@ -23,13 +23,11 @@ class RenderStateElement { if (!isLocal) { return null; } - if (reconciled && sent) { - if (!reconciledOffline && !sentOffline) { - return MessageSendState.delivered; - } - return MessageSendState.sent; - } + if (sent && !sentOffline) { + return MessageSendState.delivered; + } + if (reconciled && !reconciledOffline) { return MessageSendState.sent; } return MessageSendState.sending; diff --git a/lib/contact_invitation/views/invitation_dialog.dart b/lib/contact_invitation/views/invitation_dialog.dart index 60d8784..2f1bd1c 100644 --- a/lib/contact_invitation/views/invitation_dialog.dart +++ b/lib/contact_invitation/views/invitation_dialog.dart @@ -224,8 +224,13 @@ class InvitationDialogState extends State { _validInvitation = null; widget.onValidationFailed(); }); - } on VeilidAPIException { - final errorText = translate('invitation_dialog.invalid_invitation'); + } on VeilidAPIException catch (e) { + late final String errorText; + if (e is VeilidAPIExceptionTryAgain) { + errorText = translate('invitation_dialog.try_again_online'); + } else { + errorText = translate('invitation_dialog.invalid_invitation'); + } if (mounted) { showErrorToast(context, errorText); } diff --git a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart index af16842..f7df9a9 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart @@ -390,14 +390,14 @@ class DHTRecord { // range we care about, don't pass it through final overlappedFirstSubkey = overlappedSubkeys.firstSubkey; final updateFirstSubkey = subkeys.firstSubkey; - final updatedData = (overlappedFirstSubkey != null && - updateFirstSubkey != null && - overlappedFirstSubkey == updateFirstSubkey) - ? data - : null; - // Report only watched subkeys - watchController?.add(DHTRecordWatchChange( - local: local, data: updatedData, subkeys: overlappedSubkeys)); + if (overlappedFirstSubkey != null && updateFirstSubkey != null) { + final updatedData = + overlappedFirstSubkey == updateFirstSubkey ? data : null; + + // Report only watched subkeys + watchController?.add(DHTRecordWatchChange( + local: local, data: updatedData, subkeys: overlappedSubkeys)); + } } } }