mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-04 16:01:07 +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 {
|
Future<void> setCustomVar(String value) async {
|
||||||
if (!isConnected) return;
|
if (!isConnected) return;
|
||||||
await sendFrame(buildSetCustomVarFrame(value));
|
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') {
|
if (value == 'gps:1') {
|
||||||
_startGpsLocationPolling();
|
_startGpsLocationPolling();
|
||||||
} else if (value == 'gps:0') {
|
} else if (value == 'gps:0') {
|
||||||
|
|||||||
Reference in New Issue
Block a user