Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error to callback #2439

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _This release is scheduled to be released on 2021-04-01._
- Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP.
- Respect parameter ColoredSymbolOnly also for custom events
- Added a new parameter to hide time portion on relative times
- [`module.show` has now the option for a callback on error.](https://github.com/MichMich/MagicMirror/pull/2439)

### Updated

Expand Down
3 changes: 3 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ var MM = (function () {
// Otherwise cancel show action.
if (module.lockStrings.length !== 0 && options.force !== true) {
Log.log("Will not show " + module.name + ". LockStrings active: " + module.lockStrings.join(","));
if (typeof options.onError === "function") {
options.onError(new Error("ERR_ACTIVE_LOCK_STRINGS"));
}
return;
}

Expand Down
5 changes: 2 additions & 3 deletions js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,11 @@ var Module = Class.extend({
callback = callback || function () {};
options = options || {};

var self = this;
MM.showModule(
this,
speed,
function () {
self.resume();
() => {
this.resume();
callback();
},
options
Expand Down