From e0606b33f1912bd0ce3d9257db7d9ec9ed0c23cf Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Mon, 06 Apr 2026 15:44:00 +0200
Subject: [PATCH] fix: disable MQTT autoReconnect to prevent connection flickering on resume

---
 lib/services/mqtt_service.dart |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/services/mqtt_service.dart b/lib/services/mqtt_service.dart
index 285c6bf..4ec3ae9 100644
--- a/lib/services/mqtt_service.dart
+++ b/lib/services/mqtt_service.dart
@@ -440,7 +440,9 @@
       );
       _mqttLog('MQTT: connect result=${result?.state}');
       if (result?.state == MqttConnectionState.connected) {
-        client.autoReconnect = true; // Now enable auto-reconnect for the live connection
+        // Don't enable autoReconnect — we handle reconnection ourselves
+        // in didChangeAppLifecycleState(resumed). The library's autoReconnect
+        // competes with our force-reconnect and causes connection flickering.
         return true;
       }
       _client = null;

--
Gitblit v1.3.1