mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #1770 from buxxi/develop
Changes to the clock module regarding the notifications sent.
This commit is contained in:
commit
ba4f48662f
@ -24,12 +24,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Updated
|
||||
- Updatenotification module: Display update notification for a limited (configurable) time.
|
||||
- The css/custom.css will be rename after the next release. We've add into `run-start.sh` a instruction by GIT to ignore with `--skip-worktree` and `rm --cached`. The history about this change [#1540].
|
||||
- Disable sending of notification CLOCK_SECOND when displaySeconds is false
|
||||
|
||||
### Fixed
|
||||
- Updatenotification module: Properly handle race conditions, prevent crash.
|
||||
- Send `NEWS_FEED` notification also for the first news messages which are shown
|
||||
- Fixed issue where weather module would not refresh data after a network or API outage [#1722](https://github.com/MichMich/MagicMirror/issues/1722)
|
||||
- Fixed weatherforecast module not displaying rain amount on fallback endpoint
|
||||
- Notifications CLOCK_SECOND & CLOCK_MINUTE being from startup instead of matched against the clock and avoid drifting
|
||||
|
||||
## [2.8.0] - 2019-07-01
|
||||
|
||||
|
@ -41,26 +41,40 @@ Module.register("clock",{
|
||||
|
||||
// Schedule update interval.
|
||||
var self = this;
|
||||
self.second = 0;
|
||||
self.minute = 0;
|
||||
self.lastDisplayedMinute = null;
|
||||
setInterval(function() {
|
||||
if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) {
|
||||
self.second = moment().second();
|
||||
self.minute = moment().minute();
|
||||
|
||||
//Calculate how many ms should pass until next update depending on if seconds is displayed or not
|
||||
var delayCalculator = function(reducedSeconds) {
|
||||
if (self.config.displaySeconds) {
|
||||
return 1000 - moment().milliseconds();
|
||||
} else {
|
||||
return ((60 - reducedSeconds) * 1000) - moment().milliseconds();
|
||||
}
|
||||
};
|
||||
|
||||
//A recursive timeout function instead of interval to avoid drifting
|
||||
var notificationTimer = function() {
|
||||
self.updateDom();
|
||||
}
|
||||
if (self.second === 59) {
|
||||
self.second = 0;
|
||||
if (self.minute === 59){
|
||||
self.minute = 0;
|
||||
} else {
|
||||
self.minute++;
|
||||
}
|
||||
self.sendNotification("CLOCK_MINUTE", self.minute);
|
||||
} else {
|
||||
self.second++;
|
||||
|
||||
//If seconds is displayed CLOCK_SECOND-notification should be sent (but not when CLOCK_MINUTE-notification is sent)
|
||||
if (self.config.displaySeconds) {
|
||||
self.second = (self.second + 1) % 60;
|
||||
if (self.second !== 0) {
|
||||
self.sendNotification("CLOCK_SECOND", self.second);
|
||||
setTimeout(notificationTimer, delayCalculator(0));
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
//If minute changed or seconds isn't displayed send CLOCK_MINUTE-notification
|
||||
self.minute = (self.minute + 1) % 60;
|
||||
self.sendNotification("CLOCK_MINUTE", self.minute);
|
||||
setTimeout(notificationTimer, delayCalculator(0));
|
||||
};
|
||||
|
||||
//Set the initial timeout with the amount of seconds elapsed as reducedSeconds so it will trigger when the minute changes
|
||||
setTimeout(notificationTimer, delayCalculator(self.second));
|
||||
|
||||
// Set locale.
|
||||
moment.locale(config.language);
|
||||
|
Loading…
x
Reference in New Issue
Block a user