fix(device): fix IpcRenderer empty data messages (#503)

* fix(device): fix IpcRenderer empty data messages

If IpcRenderer send null / undefined data as argument then IpcMain parse
it as empty array and not a NULL object

* fix else line break
This commit is contained in:
Róbert Kiss
2017-12-02 22:40:54 +01:00
committed by László Monda
parent 95d1d7f8b5
commit 58b1b9b1dc
3 changed files with 13 additions and 7 deletions

View File

@@ -16,8 +16,8 @@
"dependencies": {
"node-hid": "0.5.7"
},
"dataModelVersion": "1.0.0",
"usbProtocolVersion": "1.2.0",
"slaveProtocolVersion": "2.1.0",
"firmwareVersion": "3.0.0"
"firmwareVersion": "4.0.0",
"dataModelVersion": "3.0.0",
"usbProtocolVersion": "2.0.0",
"slaveProtocolVersion": "3.0.0"
}

View File

@@ -144,7 +144,7 @@ export class DeviceService {
try {
this.stopPollTimer();
if (data) {
if (data && data.length > 0) {
firmwarePathData = await saveTmpFirmware(data);
await this.operations.updateRightFirmware(firmwarePathData.rightFirmwarePath);
await this.operations.updateLeftModule(firmwarePathData.leftFirmwarePath);
@@ -162,7 +162,9 @@ export class DeviceService {
response.error = err;
}
await emptyDir(firmwarePathData.tmpDirectory.name);
if (firmwarePathData) {
await emptyDir(firmwarePathData.tmpDirectory.name);
}
await snooze(500);
event.sender.send(IpcEvents.device.updateFirmwareReply, response);

View File

@@ -35,7 +35,11 @@ export class DeviceRendererService {
}
updateFirmware(data?: Array<number>): void {
this.ipcRenderer.send(IpcEvents.device.updateFirmware, JSON.stringify(data));
if (data) {
this.ipcRenderer.send(IpcEvents.device.updateFirmware, JSON.stringify(data));
} else {
this.ipcRenderer.send(IpcEvents.device.updateFirmware);
}
}
startConnectionPoller(): void {