From 74840d3baf17c667bc1776ea7efeedcee06c2263 Mon Sep 17 00:00:00 2001 From: zjs81 Date: Fri, 8 May 2026 13:37:51 -0700 Subject: [PATCH] Optimistically update currentCustomVars in setCustomVar Reflect the set value immediately so UI bound to currentCustomVars (e.g. the GPS toggle in settings) updates on tap rather than waiting for a later device-info refresh. --- lib/connector/meshcore_connector.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 1440e63d..6bbe2fd4 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -3295,6 +3295,13 @@ class MeshCoreConnector extends ChangeNotifier { Future setCustomVar(String value) async { if (!isConnected) return; await sendFrame(buildSetCustomVarFrame(value)); + final sep = value.indexOf(':'); + if (sep > 0) { + final key = value.substring(0, sep); + final val = value.substring(sep + 1); + (_currentCustomVars ??= {})[key] = val; + notifyListeners(); + } if (value == 'gps:1') { _startGpsLocationPolling(); } else if (value == 'gps:0') {