homebridge-xbox-tv 3.1.4 → 3.1.5

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.
package/CHANGELOG.md CHANGED
@@ -5,11 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ### NOTE
8
+ ### NOTE!!!
9
9
 
10
- ### After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
11
-
12
- ### After update to v3.0.0 RESTFull and MQTT config settings need to be updated
10
+ - After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
11
+ - After update to v3.0.0 RESTFull and MQTT config settings need to be updated
13
12
 
14
13
  ## [3.1.4] - (06.09.2024)
15
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "3.1.4",
4
+ "version": "3.1.5",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -398,9 +398,9 @@ class XBOXLOCALAPI extends EventEmitter {
398
398
 
399
399
  async saveData(path, data) {
400
400
  try {
401
- await fsPromises.writeFile(path, JSON.stringify(data, null, 2));
402
- const debug = this.debugLog ? this.emit('debug', `Saved data: ${JSON.stringify(data, null, 2)}`) : false;
403
-
401
+ data = JSON.stringify(data, null, 2);
402
+ await fsPromises.writeFile(path, data);
403
+ const debug = this.debugLog ? this.emit('debug', `Saved data: ${data}`) : false;
404
404
  return true;
405
405
  } catch (error) {
406
406
  throw new Error(error);
@@ -244,11 +244,12 @@ class XBOXWEBAPI extends EventEmitter {
244
244
  'name': name,
245
245
  'contentType': contentType
246
246
  };
247
- appsArray.push(inputsObj);
247
+ const duplicatedInput = appsArray.some(input => input.reference === aumid);
248
+ const push = name && aumid && !duplicatedInput ? appsArray.push(inputsObj) : false;
248
249
  };
249
250
 
250
- //save apps to the file
251
- await this.saveInputs(this.inputsFile, appsArray);
251
+ //save inputs
252
+ await this.saveData(this.inputsFile, appsArray);
252
253
 
253
254
  //emit restFul and mqtt
254
255
  this.emit('restFul', 'apps', apps);
@@ -346,28 +347,15 @@ class XBOXWEBAPI extends EventEmitter {
346
347
  };
347
348
  }
348
349
 
349
- async saveInputs(path, appsArray) {
350
+ async saveData(path, data) {
350
351
  try {
351
- const inputs = [...CONSTANTS.DefaultInputs, ...appsArray];
352
-
353
- //chack duplicated inputs
354
- const inputsArr = [];
355
- for (const input of inputs) {
356
- const inputName = input.name;
357
- const inputReference = input.reference;
358
- const duplicatedInput = inputsArr.some(input => input.reference === inputReference);
359
- const push = inputName && inputReference && !duplicatedInput ? inputsArr.push(input) : false;
360
- }
361
-
362
- //save inputs
363
- const allInputs = JSON.stringify(inputsArr, null, 2);
364
- await fsPromises.writeFile(path, allInputs);
365
- const debug = this.debugLog ? this.emit('debug', `Saved apps: ${allInputs}`) : false;
366
-
352
+ data = JSON.stringify(data, null, 2);
353
+ await fsPromises.writeFile(path, data);
354
+ const debug = this.debugLog ? this.emit('debug', `Saved data: ${data}`) : false;
367
355
  return true;
368
356
  } catch (error) {
369
357
  throw new Error(error);
370
- }
358
+ };
371
359
  };
372
360
 
373
361
  async next() {