mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
feat: improve message matching logic and update notification IDs for advertisements
This commit is contained in:
parent
71f59d23df
commit
91608ff09e
3 changed files with 7 additions and 16 deletions
1
.swift-version
Normal file
1
.swift-version
Normal file
|
|
@ -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',
|
||||
);
|
||||
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -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<void> clearAdvertNotifications(List<String> contactIds) async {
|
||||
if (!await _ensureInitialized()) return;
|
||||
for (final id in contactIds) {
|
||||
await _notifications.cancel(id: id.hashCode);
|
||||
await _notifications.cancel(id: 'advert:$id'.hashCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue