()
| 59 | |
| 60 | // A recursive timeout function instead of interval to avoid drifting |
| 61 | const notificationTimer = () => { |
| 62 | this.updateDom(); |
| 63 | |
| 64 | if (this.config.sendNotifications) { |
| 65 | // If seconds is displayed CLOCK_SECOND-notification should be sent (but not when CLOCK_MINUTE-notification is sent) |
| 66 | if (this.config.displaySeconds) { |
| 67 | this.second = moment().second(); |
| 68 | if (this.second !== 0) { |
| 69 | this.sendNotification("CLOCK_SECOND", this.second); |
| 70 | setTimeout(notificationTimer, delayCalculator(0)); |
| 71 | return; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // If minute changed or seconds isn't displayed send CLOCK_MINUTE-notification |
| 76 | this.minute = moment().minute(); |
| 77 | this.sendNotification("CLOCK_MINUTE", this.minute); |
| 78 | } |
| 79 | |
| 80 | setTimeout(notificationTimer, delayCalculator(0)); |
| 81 | }; |
| 82 | |
| 83 | // Set the initial timeout with the amount of seconds elapsed as |
| 84 | // reducedSeconds, so it will trigger when the minute changes |
nothing calls this directly
no test coverage detected