mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Create new group chat for the same group
This commit is contained in:
@@ -41,6 +41,7 @@ import {
|
|||||||
group_generation_id,
|
group_generation_id,
|
||||||
getGroupChat,
|
getGroupChat,
|
||||||
renameGroupMember,
|
renameGroupMember,
|
||||||
|
createNewGroupChat,
|
||||||
} from "./scripts/group-chats.js";
|
} from "./scripts/group-chats.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -4303,18 +4304,24 @@ $(document).ready(function () {
|
|||||||
//Make a new chat for selected character
|
//Make a new chat for selected character
|
||||||
if (
|
if (
|
||||||
popup_type == "new_chat" &&
|
popup_type == "new_chat" &&
|
||||||
this_chid != undefined &&
|
(selected_group || this_chid !== undefined) &&
|
||||||
menu_type != "create"
|
menu_type != "create"
|
||||||
) {
|
) {
|
||||||
//Fix it; New chat doesn't create while open create character menu
|
//Fix it; New chat doesn't create while open create character menu
|
||||||
clearChat();
|
clearChat();
|
||||||
chat.length = 0;
|
chat.length = 0;
|
||||||
chat_metadata = {};
|
|
||||||
characters[this_chid].chat = name2 + " - " + humanizedDateTime(); //RossAscends: added character name to new chat filenames and replaced Date.now() with humanizedDateTime;
|
|
||||||
$("#selected_chat_pole").val(characters[this_chid].chat);
|
|
||||||
saveCharacterDebounced();
|
|
||||||
getChat();
|
|
||||||
|
|
||||||
|
if (selected_group) {
|
||||||
|
createNewGroupChat();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//RossAscends: added character name to new chat filenames and replaced Date.now() with humanizedDateTime;
|
||||||
|
chat_metadata = {};
|
||||||
|
characters[this_chid].chat = name2 + " - " + humanizedDateTime();
|
||||||
|
$("#selected_chat_pole").val(characters[this_chid].chat);
|
||||||
|
saveCharacterDebounced();
|
||||||
|
getChat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogueResolve) {
|
if (dialogueResolve) {
|
||||||
@@ -4664,13 +4671,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (id == "option_start_new_chat") {
|
else if (id == "option_start_new_chat") {
|
||||||
if (selected_group) {
|
if ((selected_group || this_chid !== undefined) && !is_send_press) {
|
||||||
// will open a group creation screen
|
|
||||||
/* openNavToggle(); */
|
|
||||||
$("#rm_button_group_chats").trigger("click");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this_chid != undefined && !is_send_press) {
|
|
||||||
popup_type = "new_chat";
|
popup_type = "new_chat";
|
||||||
callPopup("<h3>Start new chat?</h3>");
|
callPopup("<h3>Start new chat?</h3>");
|
||||||
}
|
}
|
||||||
|
@@ -1077,6 +1077,30 @@ function filterMembersByFavorites(value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function createNewGroupChat() {
|
||||||
|
const group = groups.find(x => x.id === selected_group);
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldChatName = group.chat_id;
|
||||||
|
const newChatName = humanizedDateTime();
|
||||||
|
|
||||||
|
if (typeof group.past_metadata !== 'object') {
|
||||||
|
group.past_metadata = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
group.past_metadata[oldChatName] = Object.assign({}, chat_metadata);
|
||||||
|
group.chats.push(newChatName);
|
||||||
|
group.chat_id = newChatName;
|
||||||
|
group.chat_metadata = {};
|
||||||
|
updateChatMetadata(group.chat_metadata, true);
|
||||||
|
|
||||||
|
await editGroup(group.id, true);
|
||||||
|
await getGroupChat(group.id);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$(document).on("click", ".group_select", selectGroup);
|
$(document).on("click", ".group_select", selectGroup);
|
||||||
$("#rm_group_filter").on("input", filterGroupMembers);
|
$("#rm_group_filter").on("input", filterGroupMembers);
|
||||||
|
Reference in New Issue
Block a user