Add RENAMED_PAST_CHAT event

4e1cb1eba40bacaead6ede5ba6da265157928c60

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +8 -5Ignore whitespace
public/script.js+8 -5
@@ -500,6 +500,7 @@ export const event_types = {
500500 CHARACTER_DELETED: 'characterDeleted',
501501 CHARACTER_DUPLICATED: 'character_duplicated',
502502 CHARACTER_RENAMED: 'character_renamed',
503+ RENAMED_PAST_CHAT: 'renamed_past_chat',
503504 /** @deprecated The event is aliased to STREAM_TOKEN_RECEIVED. */
504505 SMOOTH_STREAM_TOKEN_RECEIVED: 'stream_token_received',
505506 STREAM_TOKEN_RECEIVED: 'stream_token_received',
@@ -6359,7 +6360,7 @@ export async function renameCharacter(name = null, { silent = false, renameChats
63596360 <i><b>Sprites folder (if any) should be renamed manually.</b></i>`, 'confirm');
63606361
63616362 if (renamePastChatsConfirm) {
63626363 await renamePastChats(oldAvatar, newAvatar, newValue);
63636364 await reloadCurrentChat();
63646365 toastr.success(t`Character renamed and past chats updated!`, t`Rename Character`);
63656366 } else {
@@ -6387,7 +6388,7 @@ export async function renameCharacter(name = null, { silent = false, renameChats
63876388 return true;
63886389}
63896390
63906391async function renamePastChats(oldAvatar, newAvatar, newValuenewName) {
63916392 const pastChats = await getPastCharacterChats();
63926393
63936394 for (const { file_name } of pastChats) {
@@ -6397,7 +6398,7 @@ async function renamePastChats(newAvatar, newValue) {
63976398 method: 'POST',
63986399 headers: getRequestHeaders(),
63996400 body: JSON.stringify({
64006401 ch_name: newValuenewName,
64016402 file_name: fileNameWithoutExtension,
64026403 avatar_url: newAvatar,
64036404 }),
@@ -6413,15 +6414,17 @@ async function renamePastChats(newAvatar, newValue) {
64136414 }
64146415
64156416 if (message.name !== undefined) {
64166417 message.name = newValuenewName;
64176418 }
64186419 }
64196420
6421+ await eventSource.emit(event_types.RENAMED_PAST_CHAT, currentChat, oldAvatar, newAvatar);
6422+
64206423 const saveChatResponse = await fetch('/api/chats/save', {
64216424 method: 'POST',
64226425 headers: getRequestHeaders(),
64236426 body: JSON.stringify({
64246427 ch_name: newValuenewName,
64256428 file_name: fileNameWithoutExtension,
64266429 chat: currentChat,
64276430 avatar_url: newAvatar,