back to parent chat speed up by not checking for file and if there is an error or no file then send a warning.
Signed| @@ -7417,7 +7417,16 @@ export async function openCharacterChat(file_name) { | |||
| 7417 | characters[this_chid]['chat'] = file_name; | 7417 | characters[this_chid]['chat'] = file_name; |
| 7418 | chat.length = 0; | 7418 | chat.length = 0; |
| 7419 | chat_metadata = {}; | 7419 | chat_metadata = {}; |
| 7420 | await getChat(); | 7420 | try { |
| 7421 | await getChat(); | ||
| 7422 | if (chat.length === 0) { | ||
| 7423 | toastr.warning('Chat file not found: ' + file_name); | ||
| 7424 | return; | ||
| 7425 | } | ||
| 7426 | } catch (e) { | ||
| 7427 | toastr.warning('Chat file not found: ' + file_name); | ||
| 7428 | return; | ||
| 7429 | } | ||
| 7421 | $('#selected_chat_pole').val(file_name); | 7430 | $('#selected_chat_pole').val(file_name); |
| 7422 | await createOrEditCharacter(new CustomEvent('newChat')); | 7431 | await createOrEditCharacter(new CustomEvent('newChat')); |
| 7423 | } | 7432 | } |
| @@ -238,17 +238,11 @@ export function updateBookmarkDisplay(mes, newBookmarkLink = null) { | |||
| 238 | 238 | ||
| 239 | async function backToMainChat() { | 239 | async function backToMainChat() { |
| 240 | const mainChatName = getMainChatName(); | 240 | const mainChatName = getMainChatName(); |
| 241 | const allChats = await getExistingChatNames(); | 241 | if (selected_group) { |
| 242 | 242 | await openGroupChat(selected_group, mainChatName); | |
| 243 | if (allChats.includes(mainChatName)) { | 243 | } else { |
| 244 | if (selected_group) { | 244 | await openCharacterChat(mainChatName); |
| 245 | await openGroupChat(selected_group, mainChatName); | ||
| 246 | } else { | ||
| 247 | await openCharacterChat(mainChatName); | ||
| 248 | } | ||
| 249 | return mainChatName; | ||
| 250 | } | 245 | } |
| 251 | |||
| 252 | return null; | 246 | return null; |
| 253 | } | 247 | } |
| 254 | 248 | ||
| @@ -266,6 +266,10 @@ export async function getGroupChat(groupId, reload = false) { | |||
| 266 | await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1), 'first_message'); | 266 | await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1), 'first_message'); |
| 267 | } | 267 | } |
| 268 | await saveGroupChat(groupId, false); | 268 | await saveGroupChat(groupId, false); |
| 269 | await printMessages(); | ||
| 270 | } else { | ||
| 271 | toastr.warning('Group chat file not found: ' + chat_id); | ||
| 272 | return; | ||
| 269 | } | 273 | } |
| 270 | } | 274 | } |
| 271 | 275 | ||