Merge branch 'KristjanESPERANTO-review'

This commit is contained in:
Edward Shen 2024-12-02 12:46:18 -08:00
commit 68e9568ccc
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -54,12 +54,12 @@ Module.register('MMM-pages', {
// Compatibility // Compatibility
if (this.config.excludes.length) { if (this.config.excludes.length) {
Log.warn('[Pages]: The config option "excludes" is deprecated. Please use "fixed" instead.'); Log.warn('[MMM-pages] The config option "excludes" is deprecated. Please use "fixed" instead.');
this.config.fixed = this.config.excludes; this.config.fixed = this.config.excludes;
} }
if (this.config.rotationFirstPage) { if (this.config.rotationFirstPage) {
Log.warn('[Pages]: The config option "rotationFirstPage" is deprecated. Please used "rotationHomePage" instead.'); Log.warn('[MMM-pages] The config option "rotationFirstPage" is deprecated. Please used "rotationHomePage" instead.');
this.config.rotationHomePage = this.config.rotationFirstPage; this.config.rotationHomePage = this.config.rotationFirstPage;
} }
@ -69,7 +69,7 @@ Module.register('MMM-pages', {
this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0); this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0);
if (!this.config.useLockString) { if (!this.config.useLockString) {
Log.log('[Pages]: User opted to not use lock strings!'); Log.log('[MMM-pages] User opted to not use lock strings!');
} }
}, },
@ -94,26 +94,24 @@ Module.register('MMM-pages', {
notificationReceived: function (notification, payload) { notificationReceived: function (notification, payload) {
switch (notification) { switch (notification) {
case 'PAGE_CHANGED': case 'PAGE_CHANGED':
Log.log('[Pages]: received a notification ' Log.log(`[MMM-pages] received a notification to change to page ${payload} of type ${typeof payload}.`);
+ `to change to page ${payload} of type ${typeof payload}`);
this.curPage = payload; this.curPage = payload;
this.updatePages(); this.updatePages();
break; break;
case 'PAGE_INCREMENT': case 'PAGE_INCREMENT':
Log.log('[Pages]: received a notification to increment pages!'); Log.log('[MMM-pages] received a notification to increment pages!');
this.changePageBy(payload, 1); this.changePageBy(payload, 1);
this.updatePages(); this.updatePages();
break; break;
case 'PAGE_DECREMENT': case 'PAGE_DECREMENT':
Log.log('[Pages]: received a notification to decrement pages!'); Log.log('[MMM-pages] received a notification to decrement pages!');
// We can't just pass in -payload for situations where payload is null // We can't just pass in -payload for situations where payload is null
// JS will coerce -payload to -0. // JS will coerce -payload to -0.
this.changePageBy(payload ? -payload : payload, -1); this.changePageBy(payload ? -payload : payload, -1);
this.updatePages(); this.updatePages();
break; break;
case 'DOM_OBJECTS_CREATED': case 'DOM_OBJECTS_CREATED':
Log.log('[Pages]: received that all objects are created;' Log.log('[MMM-pages] received that all objects are created; will now hide things!');
+ ' will now hide things!');
this.sendNotification('MAX_PAGES_CHANGED', this.config.modules.length); this.sendNotification('MAX_PAGES_CHANGED', this.config.modules.length);
this.sendNotification('NEW_PAGE', this.curPage); this.sendNotification('NEW_PAGE', this.curPage);
this.animatePageChange(); this.animatePageChange();
@ -132,12 +130,12 @@ Module.register('MMM-pages', {
this.notificationReceived('PAGE_CHANGED', this.config.homePage); this.notificationReceived('PAGE_CHANGED', this.config.homePage);
break; break;
case 'SHOW_HIDDEN_PAGE': case 'SHOW_HIDDEN_PAGE':
Log.log(`[Pages]: received a notification to change to the hidden page "${payload}" of type "${typeof payload}"`); Log.log(`[MMM-pages] received a notification to change to the hidden page "${payload}" of type "${typeof payload}".`);
this.setRotation(false); this.setRotation(false);
this.showHiddenPage(payload); this.showHiddenPage(payload);
break; break;
case 'LEAVE_HIDDEN_PAGE': case 'LEAVE_HIDDEN_PAGE':
Log.log("[Pages]: received a notification to leave the current hidden page "); Log.log('[MMM-pages] received a notification to leave the current hidden page.');
this.animatePageChange(); this.animatePageChange();
this.setRotation(true); this.setRotation(true);
break; break;
@ -157,7 +155,7 @@ Module.register('MMM-pages', {
*/ */
changePageBy: function (amt, fallback) { changePageBy: function (amt, fallback) {
if (typeof amt !== 'number' && typeof fallback === 'undefined') { if (typeof amt !== 'number' && typeof fallback === 'undefined') {
Log.warn(`[Pages]: ${amt} is not a number!`); Log.warn(`[MMM-pages] ${amt} is not a number!`);
} }
if (typeof amt === 'number' && !Number.isNaN(amt)) { if (typeof amt === 'number' && !Number.isNaN(amt)) {
@ -178,14 +176,14 @@ Module.register('MMM-pages', {
* elements. * elements.
*/ */
updatePages: function () { updatePages: function () {
// Update iff there's at least one page. // Update if there's at least one page.
if (this.config.modules.length !== 0) { if (this.config.modules.length !== 0) {
this.animatePageChange(); this.animatePageChange();
if (!this.rotationPaused) { if (!this.rotationPaused) {
this.resetTimerWithDelay(0); this.resetTimerWithDelay(0);
} }
this.sendNotification('NEW_PAGE', this.curPage); this.sendNotification('NEW_PAGE', this.curPage);
} else { Log.error("[Pages]: Pages aren't properly defined!"); } } else { Log.error('[MMM-pages] Pages are not properly defined!'); }
}, },
/** /**
@ -280,9 +278,9 @@ Module.register('MMM-pages', {
setRotation: function (isRotating) { setRotation: function (isRotating) {
const stateBaseString = (isRotating) ? "resum" : "paus"; const stateBaseString = (isRotating) ? "resum" : "paus";
if (isRotating === this.rotationPaused) { if (isRotating === this.rotationPaused) {
Log.warn(`[Pages]: Was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`); Log.warn(`[MMM-pages] was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`);
} else { } else {
Log.log(`[Pages]: ${stateBaseString}ing rotation`); Log.log(`[MMM-pages] ${stateBaseString}ing rotation`);
if (!isRotating) { if (!isRotating) {
clearInterval(this.timer); clearInterval(this.timer);
clearInterval(this.delayTimer); clearInterval(this.delayTimer);
@ -303,7 +301,7 @@ Module.register('MMM-pages', {
if (name in this.config.hiddenPages) { if (name in this.config.hiddenPages) {
this.animatePageChange(name); this.animatePageChange(name);
} else { } else {
Log.error(`Hidden page "${name}" does not exist!`); Log.error(`[MMM-pages] Hidden page "${name}" does not exist!`);
} }
}, },
}); });