Enhance validation and error handling across various screens

- Updated ConnectionProvider to track pending messages before sending to avoid race conditions.
- Integrated ValidationService in DeviceConfigScreen for validating latitude, longitude, frequency, and TX power inputs.
- Added bounds and zoom level validation in MapManagementScreen using ValidationService.
- Refactored MapTab to utilize LocationTrackingService for location updates and removed deprecated location permission handling.
- Replaced BackgroundLocationService with LocationTrackingService in SettingsScreen, improving location update management and error handling.
- Enhanced SAR Update Sheet to validate coordinates, notes length, and location accuracy before sending SAR markers.
This commit is contained in:
Janez T
2025-10-15 11:09:34 +02:00
parent 823a3c50f7
commit a6e317bc37
8 changed files with 822 additions and 378 deletions

View File

@@ -454,20 +454,20 @@ class ConnectionProvider with ChangeNotifier {
}
try {
// IMPORTANT: Track pending message BEFORE sending to avoid race condition
// The SENT response can arrive so quickly that if we track after sending,
// the callback will fire before we add the message ID to the queue.
if (messageId != null) {
_messageDeliveryTracker.trackPendingMessage(messageId);
print(' Added message ID to pending queue BEFORE sending: $messageId');
}
// Send the message
await _bleService.sendTextMessage(
contactPublicKey: contactPublicKey,
text: text,
);
// If message ID provided, add it to the pending queue via helper
// When the SENT response arrives, it will be matched with this message ID
// Note: Messages must be sent sequentially for this to work correctly
if (messageId != null) {
_messageDeliveryTracker.trackPendingMessage(messageId);
print(' Added message ID to pending queue: $messageId');
}
return true;
} catch (e) {
_error = 'Failed to send message: $e';
@@ -491,16 +491,16 @@ class ConnectionProvider with ChangeNotifier {
}
try {
// IMPORTANT: Track pending message BEFORE sending to avoid race condition
if (messageId != null) {
_messageDeliveryTracker.trackPendingMessage(messageId);
print(' Added message ID to pending queue BEFORE sending: $messageId');
}
await _bleService.sendChannelMessage(
channelIdx: channelIdx,
text: text,
);
// If message ID provided, add it to the pending queue via helper
if (messageId != null) {
_messageDeliveryTracker.trackPendingMessage(messageId);
print(' Added message ID to pending queue: $messageId');
}
} catch (e) {
_error = 'Failed to send channel message: $e';
notifyListeners();