Add RENAMED_PAST_CHAT event
| @@ -500,6 +500,7 @@ export const event_types = { | ||
| 500 | 500 | CHARACTER_DELETED: 'characterDeleted', |
| 501 | 501 | CHARACTER_DUPLICATED: 'character_duplicated', |
| 502 | 502 | CHARACTER_RENAMED: 'character_renamed', |
| 503 | + RENAMED_PAST_CHAT: 'renamed_past_chat', | |
| 503 | 504 | /** @deprecated The event is aliased to STREAM_TOKEN_RECEIVED. */ |
| 504 | 505 | SMOOTH_STREAM_TOKEN_RECEIVED: 'stream_token_received', |
| 505 | 506 | STREAM_TOKEN_RECEIVED: 'stream_token_received', |
| @@ -6359,7 +6360,7 @@ export async function renameCharacter(name = null, { silent = false, renameChats | ||
| 6359 | 6360 | <i><b>Sprites folder (if any) should be renamed manually.</b></i>`, 'confirm'); |
| 6360 | 6361 | |
| 6361 | 6362 | if (renamePastChatsConfirm) { |
| 6362 | 6363 | await renamePastChats(oldAvatar, newAvatar, newValue); |
| 6363 | 6364 | await reloadCurrentChat(); |
| 6364 | 6365 | toastr.success(t`Character renamed and past chats updated!`, t`Rename Character`); |
| 6365 | 6366 | } else { |
| @@ -6387,7 +6388,7 @@ export async function renameCharacter(name = null, { silent = false, renameChats | ||
| 6387 | 6388 | return true; |
| 6388 | 6389 | } |
| 6389 | 6390 | |
| 6390 | 6391 | async function renamePastChats(oldAvatar, newAvatar, newValuenewName) { |
| 6391 | 6392 | const pastChats = await getPastCharacterChats(); |
| 6392 | 6393 | |
| 6393 | 6394 | for (const { file_name } of pastChats) { |
| @@ -6397,7 +6398,7 @@ async function renamePastChats(newAvatar, newValue) { | ||
| 6397 | 6398 | method: 'POST', |
| 6398 | 6399 | headers: getRequestHeaders(), |
| 6399 | 6400 | body: JSON.stringify({ |
| 6400 | 6401 | ch_name: newValuenewName, |
| 6401 | 6402 | file_name: fileNameWithoutExtension, |
| 6402 | 6403 | avatar_url: newAvatar, |
| 6403 | 6404 | }), |
| @@ -6413,15 +6414,17 @@ async function renamePastChats(newAvatar, newValue) { | ||
| 6413 | 6414 | } |
| 6414 | 6415 | |
| 6415 | 6416 | if (message.name !== undefined) { |
| 6416 | 6417 | message.name = newValuenewName; |
| 6417 | 6418 | } |
| 6418 | 6419 | } |
| 6419 | 6420 | |
| 6421 | + await eventSource.emit(event_types.RENAMED_PAST_CHAT, currentChat, oldAvatar, newAvatar); | |
| 6422 | + | |
| 6420 | 6423 | const saveChatResponse = await fetch('/api/chats/save', { |
| 6421 | 6424 | method: 'POST', |
| 6422 | 6425 | headers: getRequestHeaders(), |
| 6423 | 6426 | body: JSON.stringify({ |
| 6424 | 6427 | ch_name: newValuenewName, |
| 6425 | 6428 | file_name: fileNameWithoutExtension, |
| 6426 | 6429 | chat: currentChat, |
| 6427 | 6430 | avatar_url: newAvatar, |