From 9d1aa497a7285f7c939608cb9c77fdac2a652d55 Mon Sep 17 00:00:00 2001 From: VolanDeVovan Date: Sun, 12 Apr 2020 03:44:20 +0300 Subject: [PATCH] Send across ipc only unique value (#56) * Send across ipc only unique value * Fix equality check. Co-authored-by: Daniel Scalzi --- app/assets/js/assetexec.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/js/assetexec.js b/app/assets/js/assetexec.js index 28c3af7..9d39449 100644 --- a/app/assets/js/assetexec.js +++ b/app/assets/js/assetexec.js @@ -14,12 +14,17 @@ console.log('AssetExec Started') // Temporary for debug purposes. process.on('unhandledRejection', r => console.log(r)) +let percent = 0 function assignListeners(){ tracker.on('validate', (data) => { process.send({context: 'validate', data}) }) tracker.on('progress', (data, acc, total) => { - process.send({context: 'progress', data, value: acc, total, percent: parseInt((acc/total)*100)}) + const currPercent = parseInt((acc/total) * 100) + if (currPercent !== percent) { + percent = currPercent + process.send({context: 'progress', data, value: acc, total, percent}) + } }) tracker.on('complete', (data, ...args) => { process.send({context: 'complete', data, args})