back to parent chat speed up by not checking for file and if there is an error or no file then send a warning.

fa38543b1a0b64350d52a985d76fe021a551d4a6

I <16441743+imesha10@users.noreply.github.com>

Signed
3 files changed, +13 -6Showing whitespace changes
public/script.js+9 -0
@@ -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 try {
7420 await getChat();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}
public/scripts/bookmarks.js+0 -6
@@ -238,17 +238,11 @@ export function updateBookmarkDisplay(mes, newBookmarkLink = null) {
238238
239async function backToMainChat() {239async function backToMainChat() {
240 const mainChatName = getMainChatName();240 const mainChatName = getMainChatName();
241 const allChats = await getExistingChatNames();
242
243 if (allChats.includes(mainChatName)) {
244 if (selected_group) {241 if (selected_group) {
245 await openGroupChat(selected_group, mainChatName);242 await openGroupChat(selected_group, mainChatName);
246 } else {243 } else {
247 await openCharacterChat(mainChatName);244 await openCharacterChat(mainChatName);
248 }245 }
249 return mainChatName;
250 }
251
252 return null;246 return null;
253}247}
254248
public/scripts/group-chats.js+4 -0
@@ -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 }
271275