mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +10:00
feat: improve message matching logic and update notification IDs for advertisements
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
6.2.4
|
||||||
@@ -355,24 +355,12 @@ class MessageRetryService extends ChangeNotifier {
|
|||||||
'Hash-based match failed for $ackHashHex, falling back to queue-based matching',
|
'Hash-based match failed for $ackHashHex, falling back to queue-based matching',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to identify the correct contact from _activeMessages first.
|
// Search all contact queues so concurrent chats don't miss matches.
|
||||||
String? targetContactKey;
|
final queuesToSearch = _pendingMessageQueuePerContact;
|
||||||
for (final activeId in _activeMessages) {
|
|
||||||
final activeContact = _pendingContacts[activeId];
|
|
||||||
if (activeContact != null) {
|
|
||||||
targetContactKey = activeContact.publicKeyHex;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final queuesToSearch = targetContactKey != null
|
|
||||||
? {targetContactKey: _pendingMessageQueuePerContact[targetContactKey]}
|
|
||||||
: _pendingMessageQueuePerContact;
|
|
||||||
|
|
||||||
for (var entry in queuesToSearch.entries) {
|
for (var entry in queuesToSearch.entries) {
|
||||||
final contactKey = entry.key;
|
final contactKey = entry.key;
|
||||||
final queue = entry.value;
|
final queue = entry.value;
|
||||||
if (queue == null) continue;
|
|
||||||
|
|
||||||
// Drain stale entries until we find a valid one or exhaust the queue.
|
// Drain stale entries until we find a valid one or exhaust the queue.
|
||||||
while (queue.isNotEmpty) {
|
while (queue.isNotEmpty) {
|
||||||
|
|||||||
@@ -232,7 +232,9 @@ class NotificationService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await _notifications.show(
|
await _notifications.show(
|
||||||
id: contactId?.hashCode ?? DateTime.now().millisecondsSinceEpoch,
|
id: contactId != null
|
||||||
|
? 'advert:$contactId'.hashCode
|
||||||
|
: DateTime.now().millisecondsSinceEpoch,
|
||||||
title: _l10n.notification_newTypeDiscovered(contactType),
|
title: _l10n.notification_newTypeDiscovered(contactType),
|
||||||
body: contactName,
|
body: contactName,
|
||||||
notificationDetails: notificationDetails,
|
notificationDetails: notificationDetails,
|
||||||
@@ -355,7 +357,7 @@ class NotificationService {
|
|||||||
Future<void> clearAdvertNotifications(List<String> contactIds) async {
|
Future<void> clearAdvertNotifications(List<String> contactIds) async {
|
||||||
if (!await _ensureInitialized()) return;
|
if (!await _ensureInitialized()) return;
|
||||||
for (final id in contactIds) {
|
for (final id in contactIds) {
|
||||||
await _notifications.cancel(id: id.hashCode);
|
await _notifications.cancel(id: 'advert:$id'.hashCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user