Merge pull request #1682 from kolbyjack/update/optimize-clock-update

Only call updateDom in clock.js when the content has changed
This commit is contained in:
Michael Teeuw 2019-05-19 07:34:05 +02:00 committed by GitHub
commit caf56671dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fixed the example calender url in `config.js.sample`
- Update `ical.js` to solve various calendar issues.
- Update weather city list url [#1676](https://github.com/MichMich/MagicMirror/issues/1676)
- Only update clock once per minute when seconds aren't shown
### Fixed
- Allowance HTML5 autoplay-policy (policy is changed from Chrome 66 updates)

View File

@ -41,8 +41,11 @@ Module.register("clock",{
// Schedule update interval.
var self = this;
self.lastDisplayedMinute = null;
setInterval(function() {
self.updateDom();
if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) {
self.updateDom();
}
}, 1000);
// Set locale.
@ -75,6 +78,7 @@ Module.register("clock",{
// See issue: https://github.com/MichMich/MagicMirror/issues/181
var timeString;
var now = moment();
this.lastDisplayedMinute = now.minute();
if (this.config.timezone) {
now.tz(this.config.timezone);
}