From 1c6c9efba18182f297b6755c17e27717ed05f8a8 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 27 Jun 2024 01:01:43 +0200 Subject: [PATCH] Refactor convert to group chat to new popup --- public/script.js | 2 +- public/scripts/bookmarks.js | 4 ++-- public/scripts/popup.js | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/public/script.js b/public/script.js index 507791c19..519865dec 100644 --- a/public/script.js +++ b/public/script.js @@ -8553,7 +8553,7 @@ async function doImpersonate(args, prompt) { async function doNewChat({ deleteCurrentChat = false } = {}) { //Make a new chat for selected character - if ((!selected_group && this_chid == undefined) || menu_type != 'create') { + if ((!selected_group && this_chid == undefined) || menu_type == 'create') { return; } diff --git a/public/scripts/bookmarks.js b/public/scripts/bookmarks.js index f099ba047..f6a2d1d70 100644 --- a/public/scripts/bookmarks.js +++ b/public/scripts/bookmarks.js @@ -24,6 +24,7 @@ import { saveGroupBookmarkChat, selected_group, } from './group-chats.js'; +import { Popup } from './popup.js'; import { createTagMapFromList } from './tags.js'; import { @@ -239,8 +240,7 @@ async function convertSoloToGroupChat() { return; } - const confirm = await callPopup('Are you sure you want to convert this chat to a group chat?', 'confirm'); - + const confirm = await Popup.show.confirm('Convert to group chat', 'Are you sure you want to convert this chat to a group chat?
This cannot be reverted.'); if (!confirm) { return; } diff --git a/public/scripts/popup.js b/public/scripts/popup.js index c31824f0b..d2138b722 100644 --- a/public/scripts/popup.js +++ b/public/scripts/popup.js @@ -78,8 +78,8 @@ const showPopupHelper = { /** * Asynchronously displays a confirmation popup with the given header and text, returning the clicked result button value. * - * @param {string} header - The header text for the popup. - * @param {string} text - The main text for the popup. + * @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. */ @@ -491,9 +491,17 @@ export class Popup { } class PopupUtils { + /** + * Builds popup content with header and text below + * + * @param {string} header - The header to be added to the text + * @param {string} text - The main text content + */ static BuildTextWithHeader(header, text) { - return ` -

${header}

+ if (!header) { + return text; + } + return `

${header}

${text}`; } }