remote control: /STATE/SET add optional argument to prevent widgets from sending their value

This commit is contained in:
jean-emmanuel 2023-05-13 12:21:44 +02:00
parent fe9df9c2d9
commit d0d73e4d44
3 changed files with 10 additions and 5 deletions

View file

@ -13,6 +13,9 @@
- menu: merge different interaction modes into a single `mode` property
- menu: add `swipe` mode
- remote control
- `/STATE/SET` add optional argument to prevent widgets from sending their value
## 1.24.2
- bug fixes

View file

@ -164,11 +164,12 @@ Sends back the app's state to specified target
----
#### `/STATE/SET state`
#### `/STATE/SET state send`
Set widgets' state
- `state`: `string`, json stringified object (`"widget_id": value` pairs)
- `send` (optional): `boolean`, set to `false` to prevent widgets from sending their values when the state is applied

View file

@ -206,12 +206,13 @@ var callbacks = {
},
'/STATE/SET': function(args) {
if (Array.isArray(args)) args = args[0]
if (!Array.isArray(args)) args = [args]
var json = args,
data = typeof json == 'string' ? JSON.parseFlex(json) : json
var json = args[0],
data = typeof json == 'string' ? JSON.parseFlex(json) : json,
send = !(args[1] === 0 || args[1] === false)
stateManager.set(data)
stateManager.set(data, send)
},
'/STATE/STORE': function(args) {