mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-12 08:50:30 +00:00
Remove hex logs and keep path data
This commit is contained in:
@@ -249,17 +249,14 @@ class AppProvider with ChangeNotifier {
|
||||
|
||||
/// Sync drawings from messages on app startup (before BLE connection)
|
||||
Future<void> _syncDrawingsOnStartup() async {
|
||||
// Wait for MessagesProvider to finish initializing
|
||||
// DrawingProvider loads around the same time
|
||||
// Wait for both MessagesProvider and DrawingProvider to finish initializing
|
||||
int attempts = 0;
|
||||
while (!messagesProvider.isInitialized && attempts < 20) {
|
||||
while ((!messagesProvider.isInitialized || !drawingProvider.isInitialized) &&
|
||||
attempts < 40) {
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
attempts++;
|
||||
}
|
||||
|
||||
// Give DrawingProvider a moment to finish loading too
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
_restoreSessionMetadataFromMessages();
|
||||
|
||||
debugPrint(
|
||||
@@ -975,9 +972,10 @@ class AppProvider with ChangeNotifier {
|
||||
if (AppProvider.shouldIgnoreSelfReplay(
|
||||
message: message,
|
||||
ownPublicKey: connectionProvider.deviceInfo.publicKey,
|
||||
ownName:
|
||||
connectionProvider.deviceInfo.deviceName ??
|
||||
connectionProvider.deviceInfo.selfName,
|
||||
ownName: _preferredSelfDisplayName(
|
||||
deviceName: connectionProvider.deviceInfo.deviceName,
|
||||
selfName: connectionProvider.deviceInfo.selfName,
|
||||
),
|
||||
)) {
|
||||
debugPrint('⏭️ [AppProvider] Ignoring self replay: ${message.id}');
|
||||
return;
|
||||
|
||||
@@ -22,6 +22,7 @@ class DrawingProvider with ChangeNotifier {
|
||||
|
||||
// Completed drawings
|
||||
final List<MapDrawing> _drawings = [];
|
||||
bool _isInitialized = false;
|
||||
|
||||
// In-progress drawing
|
||||
MapDrawing? _currentDrawing;
|
||||
@@ -53,6 +54,7 @@ class DrawingProvider with ChangeNotifier {
|
||||
List<LatLng> get currentLinePoints => List.unmodifiable(_currentLinePoints);
|
||||
LatLng? get rectangleStartPoint => _rectangleStartPoint;
|
||||
bool get isDrawing => _drawingMode != DrawingMode.none;
|
||||
bool get isInitialized => _isInitialized;
|
||||
LatLng? get measurementPoint1 => _measurementPoint1;
|
||||
LatLng? get measurementPoint2 => _measurementPoint2;
|
||||
double? get measuredDistance => _measuredDistance;
|
||||
@@ -61,6 +63,7 @@ class DrawingProvider with ChangeNotifier {
|
||||
Future<void> initialize() async {
|
||||
await _loadPreferences();
|
||||
await _loadDrawings();
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
/// Set drawing mode
|
||||
|
||||
@@ -28,6 +28,8 @@ class MessagesProvider with ChangeNotifier {
|
||||
final MessageStorageService _storageService = MessageStorageService();
|
||||
final NotificationService _notificationService = NotificationService();
|
||||
bool _isInitialized = false;
|
||||
bool _isPersisting = false;
|
||||
bool _persistRequested = false;
|
||||
AppLocalizations? _localizations;
|
||||
final Map<String, MessageContactLocation> _messageContactLocations = {};
|
||||
final Map<String, MessageReceptionDetails> _messageReceptionDetails = {};
|
||||
@@ -1018,18 +1020,29 @@ class MessagesProvider with ChangeNotifier {
|
||||
return '${mib.toStringAsFixed(mib >= 10 ? 0 : 1)} MB';
|
||||
}
|
||||
|
||||
/// Persist messages to storage (async, non-blocking)
|
||||
/// Persist messages to storage (async, non-blocking, coalescing).
|
||||
///
|
||||
/// Multiple rapid calls are coalesced into a single write to avoid
|
||||
/// overlapping serialization and redundant SharedPreferences writes.
|
||||
Future<void> _persistMessages() async {
|
||||
_persistRequested = true;
|
||||
if (_isPersisting) return; // A write is in flight; it will pick up our changes.
|
||||
_isPersisting = true;
|
||||
try {
|
||||
await _storageService.saveMessages(
|
||||
_messages,
|
||||
messageContactLocations: _messageContactLocations,
|
||||
messageReceptionDetails: _messageReceptionDetails,
|
||||
messageTransferDetails: _messageTransferDetails,
|
||||
messageRouteMetadata: _messageRouteMetadata,
|
||||
);
|
||||
while (_persistRequested) {
|
||||
_persistRequested = false;
|
||||
await _storageService.saveMessages(
|
||||
_messages,
|
||||
messageContactLocations: _messageContactLocations,
|
||||
messageReceptionDetails: _messageReceptionDetails,
|
||||
messageTransferDetails: _messageTransferDetails,
|
||||
messageRouteMetadata: _messageRouteMetadata,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('❌ [MessagesProvider] Error persisting messages: $e');
|
||||
} finally {
|
||||
_isPersisting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user