Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
feat: add Toggle to Enable or Disable Connection action (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
roomac authored Jun 28, 2022
1 parent 84a9260 commit 61f1668
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ instance.prototype.init_actions = function (system) {
label: 'Enable',
id: 'enable',
default: 'true',
choices: self.CHOICES_YESNO_BOOLEAN,
choices: [
{ id: 'toggle', label: 'Toggle' },
{ id: 'true', label: 'Yes' },
{ id: 'false', label: 'No' },
],
},
],
},
Expand Down Expand Up @@ -1207,7 +1211,16 @@ instance.prototype.action = function (action, extras) {
self.system.emit('variable_get', id[0], id[1], (v) => (value = v))
self.system.emit('custom_variable_set_value', opt.name, value)
} else if (id == 'instance_control') {
self.system.emit('instance_enable', opt.instance_id, opt.enable == 'true')
let newState = opt.enable == 'true'
if (opt.enable == 'toggle') {
let curState = false // no status entry if instance is disabled on startup
if (self.instance_status.hasOwnProperty(opt.instance_id)) {
curState = self.instance_status[opt.instance_id][0] == -1
}

newState = !curState
}
self.system.emit('instance_enable', opt.instance_id, newState)
} else if (id == 'set_page') {
self.changeControllerPage(theController, thePage)
} else if (id == 'set_brightness') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitfocus-companion",
"version": "1.9.1",
"version": "1.9.2",
"api_version": "1.0.0",
"description": "Internal functions",
"keywords": [],
Expand Down

0 comments on commit 61f1668

Please sign in to comment.