Refactor convert to group chat to new popup

This commit is contained in:
Wolfsblvt 2024-06-27 01:01:43 +02:00
parent efb9fbcc7e
commit 1c6c9efba1
3 changed files with 15 additions and 7 deletions

View File

@ -8553,7 +8553,7 @@ async function doImpersonate(args, prompt) {
async function doNewChat({ deleteCurrentChat = false } = {}) { async function doNewChat({ deleteCurrentChat = false } = {}) {
//Make a new chat for selected character //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; return;
} }

View File

@ -24,6 +24,7 @@ import {
saveGroupBookmarkChat, saveGroupBookmarkChat,
selected_group, selected_group,
} from './group-chats.js'; } from './group-chats.js';
import { Popup } from './popup.js';
import { createTagMapFromList } from './tags.js'; import { createTagMapFromList } from './tags.js';
import { import {
@ -239,8 +240,7 @@ async function convertSoloToGroupChat() {
return; 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?<br />This cannot be reverted.');
if (!confirm) { if (!confirm) {
return; return;
} }

View File

@ -78,8 +78,8 @@ const showPopupHelper = {
/** /**
* Asynchronously displays a confirmation popup with the given header and text, returning the clicked result button value. * 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?} header - The header text for the popup.
* @param {string} text - The main text for the popup. * @param {string?} text - The main text for the popup.
* @param {PopupOptions} [popupOptions={}] - Options for the popup. * @param {PopupOptions} [popupOptions={}] - Options for the popup.
* @return {Promise<POPUP_RESULT>} A Promise that resolves with the result of the user's interaction. * @return {Promise<POPUP_RESULT>} A Promise that resolves with the result of the user's interaction.
*/ */
@ -491,9 +491,17 @@ export class Popup {
} }
class PopupUtils { 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) { static BuildTextWithHeader(header, text) {
return ` if (!header) {
<h3>${header}</h1> return text;
}
return `<h3>${header}</h3>
${text}`; ${text}`;
} }
} }