Skip to content

Commit

Permalink
allow custom module positions by setting allowCustomModulePositions
Browse files Browse the repository at this point in the history
… in `config.js`
  • Loading branch information
khassel committed Jul 22, 2024
1 parent d9665b3 commit 2163c00
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ _This release is scheduled to be released on 2024-10-01._

### Updated

- [weather] Updated `apiVersion` default from 2.5 to 3.0
- [weather] Updated `apiVersion` default from 2.5 to 3.0 (#3424)
- [core] Allow custom module positions by setting `allowCustomModulePositions` in `config.js` (fixes #3504, related to https://github.com/MagicMirrorOrg/MagicMirror/pull/3445)

### Fixed

Expand Down
1 change: 1 addition & 0 deletions js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const defaults = {
// (interval 30 seconds). If startup-timestamp has changed the client reloads the magicmirror webpage.
checkServerInterval: 30 * 1000,
reloadAfterServerRestart: false,
allowCustomModulePositions: false,

modules: [
{
Expand Down
2 changes: 1 addition & 1 deletion js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Loader = (function () {
* @returns {object[]} module data as configured in config
*/
const getAllModules = function () {
const AllModules = config.modules.filter((module) => (module.module !== undefined) && (MM.getAvailableModulePositions.indexOf(module.position) > -1 || typeof (module.position) === "undefined"));
const AllModules = config.modules.filter((module) => (module.module !== undefined) && (MM.getAvailableModulePositions.indexOf(module.position) > -1 || typeof (module.position) === "undefined" || config.allowCustomModulePositions));
return AllModules;
};

Expand Down
1 change: 1 addition & 0 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {

// return if postion is on modulePositions Array (true/false)
moduleHasValidPosition (position) {
if (config.allowCustomModulePositions) return true;
if (this.getAvailableModulePositions().indexOf(position) === -1) return false;
return true;
}
Expand Down

0 comments on commit 2163c00

Please sign in to comment.