For some reason it looks like node fixed the scoping of this.

Removed instances of `self`.
This commit is contained in:
Edward Shen 2018-05-04 11:09:53 -04:00
parent 00b7d6d7b9
commit 4401cb411b
No known key found for this signature in database
GPG key ID: 4E887A42793D0433

View file

@ -72,7 +72,7 @@ Module.register('MMM-pages', {
break; break;
case 'PAGE_DECREMENT': case 'PAGE_DECREMENT':
Log.log(`${this.name} recieved a notification to decrement pages!`); Log.log(`${this.name} recieved a notification to decrement pages!`);
this.curPage = this.mode(this.curPage - 1, this.config.modules.length); this.curPage = this.mod(this.curPage - 1, this.config.modules.length);
this.updatePages(true); this.updatePages(true);
break; break;
case 'DOM_OBJECTS_CREATED': case 'DOM_OBJECTS_CREATED':
@ -94,7 +94,6 @@ Module.register('MMM-pages', {
updatePages(manuallyCalled) { updatePages(manuallyCalled) {
if (this.config.modules.length !== 0) { if (this.config.modules.length !== 0) {
Log.log(`updatePages was ${manuallyCalled ? '' : 'not'} manually called`); Log.log(`updatePages was ${manuallyCalled ? '' : 'not'} manually called`);
const self = this;
// Hides the current page's elements. // Hides the current page's elements.
MM.getModules() MM.getModules()
@ -110,11 +109,11 @@ Module.register('MMM-pages', {
// Shows the next page's elements // Shows the next page's elements
setTimeout(() => { setTimeout(() => {
MM.getModules() MM.getModules()
.withClass(self.config.modules[self.curPage]) .withClass(this.config.modules[this.curPage])
.enumerate((module) => { .enumerate((module) => {
module.show( module.show(
self.config.animationTime / 2, this.config.animationTime / 2,
{ lockString: self.identifier }, { lockString: this.identifier },
); );
}); });
}, this.config.animationTime / 2); }, this.config.animationTime / 2);
@ -125,18 +124,17 @@ Module.register('MMM-pages', {
clearInterval(this.timer); clearInterval(this.timer);
setTimeout(() => { setTimeout(() => {
self.timer = setInterval(() => { this.timer = setInterval(() => {
// Incrementing page // Incrementing page
this.curPage = this.mod( this.curPage = this.mod(
this.curPage + 1, this.curPage + 1,
this.config.modules.length, this.config.modules.length,
); );
self.sendNotification('PAGE_INCREMENT'); this.sendNotification('PAGE_INCREMENT');
self.updatePages(false); this.updatePages(false);
}, self.config.rotationTime, false); }, this.config.rotationTime, false);
}, this.config.rotationDelay); }, this.config.rotationDelay);
} }
} else { Log.error("Pages aren't properly defined!"); } } else { Log.error("Pages aren't properly defined!"); }
}, },
}); });