mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-11-24 03:04: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 is delay timer after manually updating.
|
||||
if(this.delayTimer){
|
||||
clearTimeout(this.delayTimer);
|
||||
this.delayTimer=null
|
||||
}
|
||||
let rotation_timeout=this.config.rotationTime
|
||||
if(this.config.pageTimeout.length){
|
||||
for(let pageInfo of this.config.pageTimeout){
|
||||
|
@ -265,9 +268,15 @@ Module.register('MMM-pages', {
|
|||
}, delay, this);
|
||||
} else if (this.config.rotationHomePage > 0) {
|
||||
// This timer is the auto rotate function.
|
||||
if(this.timer){
|
||||
(this.config.pageTimeout.length?clearTimeout:clearInterval)(this.timer);
|
||||
this.timer = null
|
||||
}
|
||||
// This is delay timer after manually updating.
|
||||
if(this.delayTimer){
|
||||
clearTimeout(this.delayTimer);
|
||||
this.delayTimer=null
|
||||
}
|
||||
let rotation_timeout=this.config.rotationHomePage
|
||||
if(this.config.pageTimeout.length){
|
||||
for(let pageInfo of this.config.pageTimeout){
|
||||
|
@ -279,6 +288,7 @@ Module.register('MMM-pages', {
|
|||
}
|
||||
const self = this;
|
||||
this.delayTimer = setTimeout(() => {
|
||||
this.delayTimer=null
|
||||
self.timer = (this.config.pageTimeout.length?setTimeout:setInterval)(() => {
|
||||
// Inform other modules and page change.
|
||||
// MagicMirror automatically excludes the sender from receiving the
|
||||
|
@ -305,9 +315,14 @@ Module.register('MMM-pages', {
|
|||
} else {
|
||||
Log.log(`[Pages]: ${stateBaseString}ing rotation`);
|
||||
if (!isRotating) {
|
||||
|
||||
if(this.timer){
|
||||
this.timer_clear_function(this.timer);
|
||||
this.timer=null
|
||||
}
|
||||
if(this.delayTimer){
|
||||
clearTimeout(this.delayTimer);
|
||||
this.delayTimer=null
|
||||
}
|
||||
} else {
|
||||
this.resetTimerWithDelay(this.rotationDelay);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue