homebridge-xbox-tv 2.8.2-beta.39 → 2.8.2-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,12 +71,10 @@
71
71
  document.querySelector('#deviceLiveId').value = pluginConfig[0].devices[i].xboxLiveId || '';
72
72
  document.querySelector('#deviceTokenInput').value = pluginConfig[0].devices[i].xboxWebApiToken || '';
73
73
  document.querySelector('#deviceWebApiControl').checked = pluginConfig[0].devices[i].webApiControl || false;
74
- const tokenLength = pluginConfig[0].devices[i].xboxWebApiToken || 0;
74
+ const tokenLength = (pluginConfig[0].devices[i].xboxWebApiToken).length || 0;
75
75
  const setCheckboxState = tokenLength <= 10 ? document.getElementById('deviceWebApiControl').checked = false : false;
76
76
  const setCheckboxMode = tokenLength <= 10 ? document.getElementById('deviceWebApiControl').disabled = true : false;
77
77
  this.deviceIndex = i;
78
-
79
- await homebridge.updatePluginConfig(pluginConfig);
80
78
  });
81
79
  this.deviceIndex = 0;
82
80
  };
@@ -88,11 +86,12 @@
88
86
  document.querySelector('#deviceTokenInput').value = pluginConfig[0].devices[0].xboxWebApiToken || '';
89
87
  document.querySelector('#deviceWebApiControl').checked = pluginConfig[0].devices[0].webApiControl || false;
90
88
 
91
- const tokenLength = (document.querySelector('#deviceTokenInput').value).length || 0;
89
+ const tokenLength = (pluginConfig[0].devices[0].xboxWebApiToken).length || '';
92
90
  const setButtonMode = tokenLength <= 10 ? document.getElementById('startAuthorizationButton').innerText = "Start authorization" : document.getElementById('startAuthorizationButton').innerText = "Check state";
93
91
  const setCheckboxState = tokenLength <= 10 ? document.getElementById('deviceWebApiControl').checked = false : false;
94
- const setCheckboxMode = tokenLength <= 10 ? document.getElementById('deviceWebApiControl').disabled = true : false;
95
92
  const setWebApiControlMode = tokenLength <= 10 ? pluginConfig[0].devices[0].webApiControl = false : false;
93
+ await homebridge.updatePluginConfig(pluginConfig);
94
+ await homebridge.savePluginConfig(pluginConfig);
96
95
 
97
96
  //watch for changes to the config button
98
97
  document.getElementById('configButton').addEventListener('click', async () => {
@@ -110,7 +109,6 @@
110
109
  const tokenLength1 = (document.querySelector('#deviceTokenInput').value).length || 0;
111
110
  const setButtonName = tokenLength1 <= 10 ? document.getElementById('startAuthorizationButton').innerText = "Start authorization" : false;
112
111
  const setButtonMode = tokenLength1 <= 10 ? document.getElementById('startAuthorizationButton').removeAttribute('disabled') : false;
113
- const setWebApiControlMode = tokenLength1 <= 10 ? pluginConfig[0].devices[this.deviceIndex].webApiControl = false : false;
114
112
 
115
113
  await homebridge.updatePluginConfig(pluginConfig);
116
114
  await homebridge.savePluginConfig(pluginConfig);
@@ -134,7 +132,6 @@
134
132
  document.getElementById('deviceWebApiControl').disabled = true;
135
133
  document.getElementById('info').innerHTML = 'Web Api Token cleared, now You can start new authorization process.';
136
134
  document.getElementById('info').style.color = 'green';
137
- homebridge.toast.info('Web Api Token cleared!', 'Info!');
138
135
  pluginConfig[0].devices[this.deviceIndex].xboxWebApiToken = '';
139
136
  pluginConfig[0].devices[this.deviceIndex].webApiControl = false;
140
137
 
@@ -144,8 +141,7 @@
144
141
 
145
142
  homebridge.hideSpinner();
146
143
  } catch (e) {
147
- document.getElementById('info').innerHTML = `Clear Web Api Token error: ${JSON.stringify(e, null, 2)}`;
148
- document.getElementById('info').style.color = 'red';
144
+ homebridge.toast.error(`Clear Web Api Token error: ${JSON.stringify(e, null, 2)}`);
149
145
  homebridge.hideSpinner();
150
146
  };
151
147
  });
@@ -228,13 +224,7 @@
228
224
  };
229
225
 
230
226
  } catch (e) {
231
- homebridge.toast.error('Failed to get data try again.', 'Error!');
232
- document.getElementById('deviceWebApiControl').checked = false;
233
- document.getElementById('deviceWebApiControl').disabled = true;
234
- pluginConfig[0].devices[this.deviceIndex].webApiControl = false;
235
-
236
- await homebridge.updatePluginConfig(pluginConfig)
237
- await homebridge.savePluginConfig(pluginConfig);
227
+ homebridge.toast.error(`Data error: ${JSON.stringify(e, null, 2)}`);
238
228
  } finally {
239
229
  homebridge.hideSpinner();
240
230
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "2.8.2-beta.39",
4
+ "version": "2.8.2-beta.40",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",