From 4e7232f13ed1599db62a96ed05a172f98a6a3aa9 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Wed, 26 Jun 2024 05:56:15 +0200 Subject: [PATCH] Move group chat popups to new popup --- public/script.js | 7 ------- public/scripts/group-chats.js | 18 +++++++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/public/script.js b/public/script.js index cd24addcb..67335b544 100644 --- a/public/script.js +++ b/public/script.js @@ -9210,13 +9210,6 @@ jQuery(async function () { if (popup_type == 'alternate_greeting' && menu_type !== 'create') { createOrEditCharacter(); } - if (popup_type === 'del_group') { - const groupId = $('#dialogue_popup').data('group_id'); - - if (groupId) { - deleteGroup(groupId); - } - } //Make a new chat for selected character if ( popup_type == 'new_chat' && diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 5b7c97953..fdc91c1df 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -24,7 +24,6 @@ import { characters, default_avatar, addOneMessage, - callPopup, clearChat, Generate, select_rm_info, @@ -75,7 +74,7 @@ import { import { printTagList, createTagMapFromList, applyTagsOnCharacterSelect, tag_map, applyTagsOnGroupSelect } from './tags.js'; import { FILTER_TYPES, FilterHelper } from './filters.js'; import { isExternalMediaAllowed } from './chats.js'; -import { POPUP_TYPE, callGenericPopup } from './popup.js'; +import { POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; export { selected_group, @@ -1300,14 +1299,20 @@ function isGroupMemberDisabled(avatarId) { return Boolean(thisGroup && thisGroup.disabled_members.includes(avatarId)); } -function onDeleteGroupClick() { +async function onDeleteGroupClick() { + if (!openGroupId) { + toastr.warning('Currently no group selected.'); + return; + } if (is_group_generating) { toastr.warning('Not so fast! Wait for the characters to stop typing before deleting the group.'); return; } - $('#dialogue_popup').data('group_id', openGroupId); - callPopup('

Delete the group?

This will also delete all your chats with that group. If you want to delete a single conversation, select a "View past chats" option in the lower left menu.

', 'del_group'); + const confirm = await Popup.show.confirm('Delete the group?', '

This will also delete all your chats with that group. If you want to delete a single conversation, select a "View past chats" option in the lower left menu.

'); + if (confirm) { + deleteGroup(openGroupId); + } } async function onFavoriteGroupClick() { @@ -1476,8 +1481,7 @@ async function uploadGroupAvatar(event) { } async function restoreGroupAvatar() { - const confirm = await callPopup('

Are you sure you want to restore the group avatar?

Your custom image will be deleted, and a collage will be used instead.', 'confirm'); - + const confirm = await Popup.show.confirm('Are you sure you want to restore the group avatar?', 'Your custom image will be deleted, and a collage will be used instead.'); if (!confirm) { return; }