mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-11-24 11:14:29 -08:00
fix timer reset if not set
This commit is contained in:
parent
b0420548b0
commit
a2eb93b259
1 changed files with 20 additions and 5 deletions
17
MMM-pages.js
17
MMM-pages.js
|
@ -243,7 +243,10 @@ Module.register('MMM-pages', {
|
||||||
this.timer=null
|
this.timer=null
|
||||||
}
|
}
|
||||||
// This is delay timer after manually updating.
|
// This is delay timer after manually updating.
|
||||||
|
if(this.delayTimer){
|
||||||
clearTimeout(this.delayTimer);
|
clearTimeout(this.delayTimer);
|
||||||
|
this.delayTimer=null
|
||||||
|
}
|
||||||
let rotation_timeout=this.config.rotationTime
|
let rotation_timeout=this.config.rotationTime
|
||||||
if(this.config.pageTimeout.length){
|
if(this.config.pageTimeout.length){
|
||||||
for(let pageInfo of this.config.pageTimeout){
|
for(let pageInfo of this.config.pageTimeout){
|
||||||
|
@ -265,9 +268,15 @@ Module.register('MMM-pages', {
|
||||||
}, delay, this);
|
}, delay, this);
|
||||||
} else if (this.config.rotationHomePage > 0) {
|
} else if (this.config.rotationHomePage > 0) {
|
||||||
// This timer is the auto rotate function.
|
// This timer is the auto rotate function.
|
||||||
|
if(this.timer){
|
||||||
(this.config.pageTimeout.length?clearTimeout:clearInterval)(this.timer);
|
(this.config.pageTimeout.length?clearTimeout:clearInterval)(this.timer);
|
||||||
|
this.timer = null
|
||||||
|
}
|
||||||
// This is delay timer after manually updating.
|
// This is delay timer after manually updating.
|
||||||
|
if(this.delayTimer){
|
||||||
clearTimeout(this.delayTimer);
|
clearTimeout(this.delayTimer);
|
||||||
|
this.delayTimer=null
|
||||||
|
}
|
||||||
let rotation_timeout=this.config.rotationHomePage
|
let rotation_timeout=this.config.rotationHomePage
|
||||||
if(this.config.pageTimeout.length){
|
if(this.config.pageTimeout.length){
|
||||||
for(let pageInfo of this.config.pageTimeout){
|
for(let pageInfo of this.config.pageTimeout){
|
||||||
|
@ -279,6 +288,7 @@ Module.register('MMM-pages', {
|
||||||
}
|
}
|
||||||
const self = this;
|
const self = this;
|
||||||
this.delayTimer = setTimeout(() => {
|
this.delayTimer = setTimeout(() => {
|
||||||
|
this.delayTimer=null
|
||||||
self.timer = (this.config.pageTimeout.length?setTimeout:setInterval)(() => {
|
self.timer = (this.config.pageTimeout.length?setTimeout:setInterval)(() => {
|
||||||
// Inform other modules and page change.
|
// Inform other modules and page change.
|
||||||
// MagicMirror automatically excludes the sender from receiving the
|
// MagicMirror automatically excludes the sender from receiving the
|
||||||
|
@ -305,9 +315,14 @@ Module.register('MMM-pages', {
|
||||||
} else {
|
} else {
|
||||||
Log.log(`[Pages]: ${stateBaseString}ing rotation`);
|
Log.log(`[Pages]: ${stateBaseString}ing rotation`);
|
||||||
if (!isRotating) {
|
if (!isRotating) {
|
||||||
|
if(this.timer){
|
||||||
this.timer_clear_function(this.timer);
|
this.timer_clear_function(this.timer);
|
||||||
|
this.timer=null
|
||||||
|
}
|
||||||
|
if(this.delayTimer){
|
||||||
clearTimeout(this.delayTimer);
|
clearTimeout(this.delayTimer);
|
||||||
|
this.delayTimer=null
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.resetTimerWithDelay(this.rotationDelay);
|
this.resetTimerWithDelay(this.rotationDelay);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue