diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 3ac6140..88c3c89 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -489,7 +489,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -511,7 +511,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
@@ -530,7 +530,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
@@ -547,7 +547,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
@@ -679,7 +679,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -702,7 +702,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
- CURRENT_PROJECT_VERSION = 108;
+ CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = JND55328G8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 75fd3fb..23eda06 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -43,7 +43,7 @@
CFBundleSignature
????
CFBundleVersion
- 108
+ 109
LSRequiresIPhoneOS
ITSAppUsesNonExemptEncryption
diff --git a/lib/providers/app_provider.dart b/lib/providers/app_provider.dart
index 883c7e8..49084fc 100644
--- a/lib/providers/app_provider.dart
+++ b/lib/providers/app_provider.dart
@@ -128,6 +128,9 @@ class AppProvider with ChangeNotifier {
Timer? _packetCaptureFlushTimer;
String? _lastPersistedPacketSignature;
bool _isPersistingPacketCapture = false;
+ bool _wasDeviceConnected = false;
+ bool _hasCompletedConnectionBootstrap = false;
+ bool _isReconnectSyncInProgress = false;
AppProvider({
required this.connectionProvider,
@@ -139,6 +142,7 @@ class AppProvider with ChangeNotifier {
required this.imageProvider,
}) {
_setupCallbacks();
+ _wasDeviceConnected = connectionProvider.deviceInfo.isConnected;
_initializeLocationTracking();
_loadMapEnabled();
_loadContactsEnabled();
@@ -1659,12 +1663,42 @@ class AppProvider with ChangeNotifier {
);
messagesProvider.syncDrawingsWithProvider(drawingProvider);
+ _hasCompletedConnectionBootstrap = true;
+ _wasDeviceConnected = connectionProvider.deviceInfo.isConnected;
notifyListeners();
} catch (e) {
debugPrint('Initialization error: $e');
}
}
+ Future _syncAfterReconnect() async {
+ if (_isReconnectSyncInProgress ||
+ !connectionProvider.deviceInfo.isConnected) {
+ return;
+ }
+
+ _isReconnectSyncInProgress = true;
+ try {
+ debugPrint(
+ '🔄 [AppProvider] Device reconnected - syncing contacts and missed messages',
+ );
+
+ await contactsProvider.initialize(
+ devicePublicKey: connectionProvider.deviceInfo.publicKey,
+ );
+ await connectionProvider.getContacts();
+
+ final messageCount = await connectionProvider.syncAllMessages();
+ debugPrint(
+ '📥 [AppProvider] Reconnect sync retrieved $messageCount message(s)',
+ );
+ } catch (e) {
+ debugPrint('❌ [AppProvider] Reconnect sync error: $e');
+ } finally {
+ _isReconnectSyncInProgress = false;
+ }
+ }
+
/// Automatically login to all rooms with saved passwords on cold connect
Future _autoLoginToRooms() async {
if (!connectionProvider.deviceInfo.isConnected) return;
@@ -2637,6 +2671,8 @@ class AppProvider with ChangeNotifier {
/// Handle connection state changes to manage location tracking
void _handleConnectionStateChange() {
final isConnected = connectionProvider.deviceInfo.isConnected;
+ final wasConnected = _wasDeviceConnected;
+ _wasDeviceConnected = isConnected;
final wasTracking = locationTrackingService.isTracking;
// Only stop tracking on disconnect - DON'T start on connect
@@ -2648,6 +2684,10 @@ class AppProvider with ChangeNotifier {
);
_stopLocationTracking();
}
+
+ if (isConnected && !wasConnected && _hasCompletedConnectionBootstrap) {
+ unawaited(_syncAfterReconnect());
+ }
}
/// Start location tracking