diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..31b44b0 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +6.2.4 \ No newline at end of file diff --git a/lib/services/message_retry_service.dart b/lib/services/message_retry_service.dart index df81d16..56d7b82 100644 --- a/lib/services/message_retry_service.dart +++ b/lib/services/message_retry_service.dart @@ -355,24 +355,12 @@ class MessageRetryService extends ChangeNotifier { 'Hash-based match failed for $ackHashHex, falling back to queue-based matching', ); - // Try to identify the correct contact from _activeMessages first. - String? targetContactKey; - for (final activeId in _activeMessages) { - final activeContact = _pendingContacts[activeId]; - if (activeContact != null) { - targetContactKey = activeContact.publicKeyHex; - break; - } - } - - final queuesToSearch = targetContactKey != null - ? {targetContactKey: _pendingMessageQueuePerContact[targetContactKey]} - : _pendingMessageQueuePerContact; + // Search all contact queues so concurrent chats don't miss matches. + final queuesToSearch = _pendingMessageQueuePerContact; for (var entry in queuesToSearch.entries) { final contactKey = entry.key; final queue = entry.value; - if (queue == null) continue; // Drain stale entries until we find a valid one or exhaust the queue. while (queue.isNotEmpty) { diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 4ed59d0..62d3796 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -232,7 +232,9 @@ class NotificationService { try { await _notifications.show( - id: contactId?.hashCode ?? DateTime.now().millisecondsSinceEpoch, + id: contactId != null + ? 'advert:$contactId'.hashCode + : DateTime.now().millisecondsSinceEpoch, title: _l10n.notification_newTypeDiscovered(contactType), body: contactName, notificationDetails: notificationDetails, @@ -355,7 +357,7 @@ class NotificationService { Future clearAdvertNotifications(List contactIds) async { if (!await _ensureInitialized()) return; for (final id in contactIds) { - await _notifications.cancel(id: id.hashCode); + await _notifications.cancel(id: 'advert:$id'.hashCode); } }