(newStatus)
| 35 | const url = activePeer.url; |
| 36 | |
| 37 | function changeStatusTo(newStatus) { |
| 38 | if (node.status !== newStatus) { |
| 39 | node.status = newStatus; |
| 40 | node |
| 41 | .save() |
| 42 | .then(() => { |
| 43 | db.syncable.on.statusChanged.fire(newStatus, url); |
| 44 | // Also broadcast message to other nodes about the status |
| 45 | db.observable.broadcastMessage( |
| 46 | 'syncStatusChanged', |
| 47 | { newStatus: newStatus, url: url }, |
| 48 | false |
| 49 | ); |
| 50 | }) |
| 51 | .catch('DatabaseClosedError', () => {}); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | activePeer.on('disconnect', function (newStatus) { |
| 56 | if (!isNaN(newStatus)) changeStatusTo(newStatus); |
no test coverage detected