feat: improve message matching logic and update notification IDs for advertisements

This commit is contained in:
zjs81
2026-03-14 09:44:37 -07:00
parent 71f59d23df
commit 91608ff09e
3 changed files with 7 additions and 16 deletions
+2 -14
View File
@@ -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) {