diff --git a/CHANGELOG.md b/CHANGELOG.md index 926d2883..d4b222fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/resources/docs/docs/remote-control.md b/resources/docs/docs/remote-control.md index 30ad24ca..27b75a5a 100644 --- a/resources/docs/docs/remote-control.md +++ b/resources/docs/docs/remote-control.md @@ -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 diff --git a/src/client/remote-control.js b/src/client/remote-control.js index b87a6d92..64253209 100644 --- a/src/client/remote-control.js +++ b/src/client/remote-control.js @@ -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) {