Skip to content

Commit

Permalink
fix(message): only call callbacks if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaju committed Jul 9, 2020
1 parent c02695e commit 6da0bf4
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/js/dialogs/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Message(writer, parentEl) {
var value = w.dialogManager.getDialogPref(config.showConfirmKey);
if (value === false) {
// user has disabled this confirm so just do the callback
config.callback(true);
if (config.callback) config.callback(true);
return;
}
}
Expand All @@ -106,11 +106,9 @@ function Message(writer, parentEl) {
w.dialogManager.setDialogPref(config.showConfirmKey, value);
}
$message.dialog('close');
// make sure dialog closes before callback
setTimeout(function() {
callback(true);
}, 0);
if (callback) setTimeout(() => callback(true), 0); // make sure dialog closes before callback
},
},
},{
text: noText,
role: 'no',
Expand All @@ -120,12 +118,9 @@ function Message(writer, parentEl) {
w.dialogManager.setDialogPref(config.showConfirmKey, value);
}
$message.dialog('close');
// make sure dialog closes before callback
setTimeout(function() {
callback(false);
}, 0);
}
}
if (callback) setTimeout(() => callback(false), 0); // make sure dialog closes before callback
},
},
]);
$message.dialog('open');
},
Expand Down

0 comments on commit 6da0bf4

Please sign in to comment.