mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +10:00
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.
This commit is contained in:
@@ -3295,6 +3295,13 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
Future<void> 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 ??= <String, String>{})[key] = val;
|
||||
notifyListeners();
|
||||
}
|
||||
if (value == 'gps:1') {
|
||||
_startGpsLocationPolling();
|
||||
} else if (value == 'gps:0') {
|
||||
|
||||
Reference in New Issue
Block a user