Skip to content

Commit

Permalink
fix: correctly show heal process complete (#980)
Browse files Browse the repository at this point in the history
Fixes #969
  • Loading branch information
robertsLando authored Mar 31, 2021
1 parent 6055834 commit f2efd4e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function driverReady () {
.on('node added', onNodeAdded.bind(this))
.on('node removed', onNodeRemoved.bind(this))
.on('heal network progress', onHealNetworkProgress.bind(this))
// .on('heal network done', onHealNetworkDone.bind(this))
.on('heal network done', onHealNetworkDone.bind(this))

for (const [, node] of this.driver.controller.nodes) {
// node added will not be triggered if the node is in cache
Expand Down Expand Up @@ -310,24 +310,17 @@ function onNodeRemoved (zwaveNode) {
function onHealNetworkProgress (progress) {
const toHeal = [...progress.values()]
const healedNodes = toHeal.filter(v => v !== 'pending')
let message
// If this is the final progress report, skip it, so the frontend gets the "done" message
if (healedNodes.length === toHeal.length) {
message = `Healing process COMPLETED. Healed ${toHeal.length} nodes`
} else {
message = `Healing process IN PROGRESS. Healed ${healedNodes.length} nodes`
}
const message = `Healing process IN PROGRESS. Healed ${healedNodes.length} nodes`
updateControllerStatus.call(this, message)

this.emit('event', eventEmitter.controller, 'heal network progress', progress)
}

function onHealNetworkDone (result) {
const message = `Healing process COMPLETED. Healed ${result.size} nodes`
updateControllerStatus.call(this, message)
}

// function onHealNetworkDone (result) {
// var message = `Healing process COMPLETED. Healed ${result.length} nodes`
// updateControllerStatus.call(this, message)
// }

// ---------- NODE EVENTS -------------------------------------

/**
Expand Down

0 comments on commit f2efd4e

Please sign in to comment.