mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-12 00:40:28 +00:00
Fix retry flow and contact filters
This commit is contained in:
@@ -1293,6 +1293,9 @@ class AppProvider with ChangeNotifier {
|
||||
retryAttempt: retryAttempt,
|
||||
);
|
||||
};
|
||||
connectionProvider.resolveContactForDmCallback = (contactPublicKey) {
|
||||
return contactsProvider.findContactByKey(contactPublicKey);
|
||||
};
|
||||
messagesProvider.onFinalRouterFallbackCallback =
|
||||
({required messageId, required contact, required message}) async {
|
||||
return _sendWithFinalNearestRouterFallback(
|
||||
@@ -1321,6 +1324,9 @@ class AppProvider with ChangeNotifier {
|
||||
roundTripTimeMs: roundTripTimeMs,
|
||||
);
|
||||
};
|
||||
messagesProvider.onManualRetryPreparedCallback = (messageId) {
|
||||
_directMessageRouteSessions.remove(messageId);
|
||||
};
|
||||
}
|
||||
|
||||
Future<Contact> _prepareDirectMessageSend({
|
||||
|
||||
@@ -185,6 +185,7 @@ class ConnectionProvider with ChangeNotifier {
|
||||
onMessageEchoDetected;
|
||||
Function(Uint8List publicKeyPrefix, Uint8List statusData)? onStatusResponse;
|
||||
Function(Uint8List payload, int snrRaw, int rssiDbm)? onRawDataReceived;
|
||||
Contact? Function(Uint8List contactPublicKey)? resolveContactForDmCallback;
|
||||
|
||||
// Track pending send operations for auto-recovery
|
||||
final Map<String, _PendingSendOperation> _pendingSendOperations = {};
|
||||
@@ -1164,6 +1165,7 @@ class ConnectionProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
var effectiveContact = contact;
|
||||
effectiveContact ??= resolveContactForDmCallback?.call(contactPublicKey);
|
||||
if (messageId != null &&
|
||||
effectiveContact != null &&
|
||||
prepareDirectMessageSendCallback != null) {
|
||||
|
||||
@@ -844,16 +844,30 @@ class ContactsProvider with ChangeNotifier {
|
||||
Uint8List publicKey, {
|
||||
required int signedEncodedPathLen,
|
||||
required Uint8List paddedPathBytes,
|
||||
LatLng? inferredFallbackLocation,
|
||||
}) {
|
||||
final contact = findContactByKey(publicKey);
|
||||
if (contact == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_contacts[contact.publicKeyHex] = contact.copyWith(
|
||||
var updatedContact = contact.copyWith(
|
||||
outPathLen: signedEncodedPathLen,
|
||||
outPath: Uint8List.fromList(paddedPathBytes),
|
||||
);
|
||||
if (inferredFallbackLocation != null) {
|
||||
updatedContact = updatedContact
|
||||
.copyWith(
|
||||
advLat: _coordinateToAdvertMicrodegrees(
|
||||
inferredFallbackLocation.latitude,
|
||||
),
|
||||
advLon: _coordinateToAdvertMicrodegrees(
|
||||
inferredFallbackLocation.longitude,
|
||||
),
|
||||
)
|
||||
.addAdvertLocation(inferredFallbackLocation, DateTime.now());
|
||||
}
|
||||
_contacts[contact.publicKeyHex] = updatedContact;
|
||||
_persistContacts();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ class MessagesProvider with ChangeNotifier {
|
||||
|
||||
Future<void> Function({required Contact contact, required int failureStreak})?
|
||||
onDirectPathFailedCallback;
|
||||
void Function(String messageId)? onManualRetryPreparedCallback;
|
||||
Future<bool> Function({
|
||||
required String messageId,
|
||||
required Contact contact,
|
||||
@@ -165,8 +166,12 @@ class MessagesProvider with ChangeNotifier {
|
||||
|
||||
final index = _messages.indexWhere((message) => message.id == messageId);
|
||||
if (index != -1) {
|
||||
final nextPathLen = selection.hopCount > 0
|
||||
? selection.hopCount
|
||||
: _messages[index].pathLen;
|
||||
_messages[index] = _messages[index].copyWith(
|
||||
usedFloodFallback: selection.usesFlood,
|
||||
pathLen: nextPathLen,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2069,6 +2074,7 @@ class MessagesProvider with ChangeNotifier {
|
||||
_clearAckHistoryForMessage(messageId);
|
||||
_retryManager.clearRetry(messageId);
|
||||
_messageRouteMetadata.remove(messageId);
|
||||
onManualRetryPreparedCallback?.call(messageId);
|
||||
|
||||
_messages[index] = Message(
|
||||
id: message.id,
|
||||
|
||||
Reference in New Issue
Block a user