From 44eccf5ee4e1905e6cc4deb9bb1579850592adaf Mon Sep 17 00:00:00 2001 From: Jon Kolb Date: Sat, 18 May 2019 20:00:53 -0400 Subject: [PATCH] Only call updateDom in clock.js when the content has changed --- CHANGELOG.md | 1 + modules/default/clock/clock.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e48b3144..1a375192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index 23b801d0..e4942076 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -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); }