Add config option to not use lockstring

This commit is contained in:
Edward Shen 2020-11-23 18:25:30 -05:00
parent 3086aa902a
commit 62c0e5900f
Signed by: edward
GPG key ID: 19182661E818369F
2 changed files with 41 additions and 27 deletions

View file

@ -18,7 +18,8 @@ Module.register('MMM-pages', {
rotationFirstPage: 0, // Keep for compatibility rotationFirstPage: 0, // Keep for compatibility
rotationHomePage: 0, rotationHomePage: 0,
rotationDelay: 10000, rotationDelay: 10000,
homePage: 0 homePage: 0,
useLockString: true,
}, },
/** /**
@ -66,6 +67,10 @@ Module.register('MMM-pages', {
this.config.rotationTime = Math.max(this.config.rotationTime, 0); this.config.rotationTime = Math.max(this.config.rotationTime, 0);
this.config.rotationDelay = Math.max(this.config.rotationDelay, 0); this.config.rotationDelay = Math.max(this.config.rotationDelay, 0);
this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0); this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0);
if (!this.config.useLockString) {
Log.log('[Pages]: User opted to not use lock strings!');
}
}, },
/** /**
@ -197,11 +202,19 @@ Module.register('MMM-pages', {
// Hides all modules not on the current page. This hides any module not // Hides all modules not on the current page. This hides any module not
// meant to be shown. // meant to be shown.
let lockStringObj = { lockString: self.identifier };
if (!this.config.useLockString) {
// Passing in an undefined object is equivalent to not passing it in at
// all, effectively providing only one arg to the hide and show calls
lockStringObj = undefined;
}
MM.getModules() MM.getModules()
.exceptWithClass(modulesToShow) .exceptWithClass(modulesToShow)
.enumerate(module => module.hide( .enumerate(module => module.hide(
self.config.animationTime / 2, self.config.animationTime / 2,
{ lockString: self.identifier } lockStringObj
)); ));
// Shows all modules meant to be on the current page, after a small delay. // Shows all modules meant to be on the current page, after a small delay.
@ -210,7 +223,7 @@ Module.register('MMM-pages', {
.withClass(modulesToShow) .withClass(modulesToShow)
.enumerate(module => module.show( .enumerate(module => module.show(
self.config.animationTime / 2, self.config.animationTime / 2,
{ lockString: self.identifier } lockStringObj
)); ));
}, this.config.animationTime / 2); }, this.config.animationTime / 2);
}, },

View file

@ -60,7 +60,7 @@ modules: [
## Configuration options ## Configuration options
| Option | Type | Default Value | Description | | Option | Type | Default Value | Description |
| ------------------- | ------------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --- | --- | --- | --- |
| `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Note that all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. | | `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Note that all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. |
| `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. | | `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
| `excludes` | *NA* | *NA* | **Deprecated**. Use `fixed` instead. | | `excludes` | *NA* | *NA* | **Deprecated**. Use `fixed` instead. |
@ -71,6 +71,7 @@ modules: [
| `rotationHomePage` | `int` | `0` | Time, in milliseconds, before automatically returning to the home page. If a home page is not set, this returns to the leftmost page instead. | | `rotationHomePage` | `int` | `0` | Time, in milliseconds, before automatically returning to the home page. If a home page is not set, this returns to the leftmost page instead. |
| `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. | | `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. |
| `homePage` | `int` | `0` | Which page index is the home page. If none is set, this returns to the leftmost page instead. | | `homePage` | `int` | `0` | Which page index is the home page. If none is set, this returns to the leftmost page instead. |
| `useLockString` | `bool` | `true` | Whether or not to use a lock string to show or hide pages. If disabled, other modules may override when modules may be shown. _Advanced users only. Only override this if you know what you're doing._
For the `module` configuration option, the first element of the outer array For the `module` configuration option, the first element of the outer array
should consist of elements that should be on the first page. The second element should consist of elements that should be on the first page. The second element
@ -81,7 +82,7 @@ should consist of elements that should be on the second page, and so forth.
The following is the list of notifications that MMM-pages will handle: The following is the list of notifications that MMM-pages will handle:
| Notification | Payload type | Description | | Notification | Payload type | Description |
| ------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --- | --- | --- |
| `PAGE_CHANGED` | `int` | MMM-pages will switch to the provided page index. | | `PAGE_CHANGED` | `int` | MMM-pages will switch to the provided page index. |
| `PAGE_INCREMENT` | `int`, Optional | MMM-pages will increment the page, or by `n` times if a number is provided. Not providing a number is equivalent to sending a payload of `1`. If there are no more pages to increment by, this will loop around to the first page. | | `PAGE_INCREMENT` | `int`, Optional | MMM-pages will increment the page, or by `n` times if a number is provided. Not providing a number is equivalent to sending a payload of `1`. If there are no more pages to increment by, this will loop around to the first page. |
| `PAGE_DECREMENT` | `int`, Optional | MMM-pages will decrement the page, or by `n` times if a number is provided. Not providing a number is equivalent to sending a payload of `1`. If there are no more pages to decrement by, this will loop around to the last page. | | `PAGE_DECREMENT` | `int`, Optional | MMM-pages will decrement the page, or by `n` times if a number is provided. Not providing a number is equivalent to sending a payload of `1`. If there are no more pages to decrement by, this will loop around to the last page. |