okay then

This commit is contained in:
Zack Rauen 2020-04-29 13:04:51 -04:00
parent ddeef1acae
commit 83c28e2649
4 changed files with 20 additions and 18 deletions

File diff suppressed because one or more lines are too long

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -78,7 +78,7 @@ BdApi.getCore = function () {
* @param {string} content - a string of text to display in the modal
*/
BdApi.alert = function (title, content) {
Utils.showConfirmationModal(title, content, {cancelText: null});
return Utils.showConfirmationModal(title, content, {cancelText: null});
};
/**
@ -91,9 +91,11 @@ BdApi.alert = function (title, content) {
* @param {string} [options.cancelText=Cancel] - text for the cancel button
* @param {callable} [options.onConfirm=NOOP] - callback to occur when clicking the submit button
* @param {callable} [options.onCancel=NOOP] - callback to occur when clicking the cancel button
* @param {string} [options.key] - key used to identify the modal. If not provided, one is generated and returned
* @returns {string} - the key used for this modal
*/
BdApi.showConfirmationModal = function (title, content, options = {}) {
Utils.showConfirmationModal(title, content, options);
return Utils.showConfirmationModal(title, content, options);
};
//Show toast alert

View File

@ -360,7 +360,7 @@ export default class Utils {
return ce(FlexChild.Child, {grow: 1, shrink: 1}, footer ? footer : defaultFooter);
};
ModalStack.push(function(props) {
return ModalStack.push(function(props) {
return ce(Changelog, Object.assign({
className: ChangelogClasses.container,
selectable: true,
@ -383,6 +383,8 @@ export default class Utils {
* @param {string} [options.cancelText=Cancel] - text for the cancel button
* @param {callable} [options.onConfirm=NOOP] - callback to occur when clicking the submit button
* @param {callable} [options.onCancel=NOOP] - callback to occur when clicking the cancel button
* @param {string} [options.key] - key used to identify the modal. If not provided, one is generated and returned
* @returns {string} - the key used for this modal
*/
static showConfirmationModal(title, content, options = {}) {
const ModalStack = WebpackModules.findByProps("push", "update", "pop", "popWithKey");
@ -391,21 +393,19 @@ export default class Utils {
if (!ModalStack || !ConfirmationModal || !Markdown) return Utils.alert(title, content);
const emptyFunction = () => {};
const {onConfirm = emptyFunction, onCancel = emptyFunction, confirmText = "Okay", cancelText = "Cancel", danger = false} = options;
const {onConfirm = emptyFunction, onCancel = emptyFunction, confirmText = "Okay", cancelText = "Cancel", danger = false, key = undefined} = options;
if (!Array.isArray(content)) content = [content];
content = content.map(c => typeof(c) === "string" ? BDV2.React.createElement(Markdown, null, c) : c);
ModalStack.push(function(props) {
return BDV2.React.createElement(ConfirmationModal, Object.assign({
header: title,
children: content,
red: danger,
confirmText: confirmText,
cancelText: cancelText,
onConfirm: onConfirm,
onCancel: onCancel
}, props));
});
return ModalStack.push(ConfirmationModal, {
header: title,
children: content,
red: danger,
confirmText: confirmText,
cancelText: cancelText,
onConfirm: onConfirm,
onCancel: onCancel
}, key);
}
}