From 2385c5a59a4b729224678b1cfe8f8a2eb642974a Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sat, 7 Sep 2024 01:21:04 +0200 Subject: [PATCH] Change popup cancel result in command to empty str --- public/scripts/popup.js | 4 ++-- public/scripts/slash-commands.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/scripts/popup.js b/public/scripts/popup.js index 7315fd536..1a9d9ce36 100644 --- a/public/scripts/popup.js +++ b/public/scripts/popup.js @@ -92,7 +92,7 @@ const showPopupHelper = { * @param {string?} header - The header text for the popup. * @param {string?} text - The main text for the popup. * @param {PopupOptions} [popupOptions={}] - Options for the popup. - * @return {Promise} A Promise that resolves with the result of the user's interaction. + * @return {Promise} A Promise that resolves with the result of the user's interaction. */ confirm: async (header, text, popupOptions = {}) => { const content = PopupUtils.BuildTextWithHeader(header, text); @@ -107,7 +107,7 @@ const showPopupHelper = { * @param {string?} header - The header text for the popup. * @param {string?} text - The main text for the popup. * @param {PopupOptions} [popupOptions={}] - Options for the popup. - * @return {Promise} A Promise that resolves with the result of the user's interaction. + * @return {Promise} A Promise that resolves with the result of the user's interaction. */ text: async (header, text, popupOptions = {}) => { const content = PopupUtils.BuildTextWithHeader(header, text); diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index e8a403f23..444639760 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -1308,7 +1308,7 @@ export function initDefaultSlashCommands() { }), SlashCommandNamedArgument.fromProps({ name: 'result', - description: 'if enabled, returns the popup result (as an integer) instead of the popup text. Resolves to 1 for OK and 0/null for cancel or exiting out.', + description: 'if enabled, returns the popup result (as an integer) instead of the popup text. Resolves to 1 for OK and 0 cancel button, empty string for exiting out.', typeList: [ARGUMENT_TYPE.BOOLEAN], enumList: commonEnumProviders.boolean('trueFalse')(), defaultValue: 'false', @@ -1938,7 +1938,7 @@ async function popupCallback(args, value) { cancelButton: args?.cancelButton !== undefined && typeof args?.cancelButton === 'string' ? args.cancelButton : null, }; const result = await Popup.show.text(safeHeader, safeBody, popupOptions); - return String(requestedResult ? result : value); + return String(requestedResult ? result ?? '' : value); } async function getMessagesCallback(args, value) {