Wait for current chat to finish saving before allowing to switch

This commit is contained in:
Cohee
2025-05-17 08:45:12 +03:00
parent 484f7e894a
commit e52b3afea9
2 changed files with 3 additions and 0 deletions

View File

@ -7299,6 +7299,7 @@ function getFirstMessage() {
} }
export async function openCharacterChat(file_name) { export async function openCharacterChat(file_name) {
await waitUntilCondition(() => !isChatSaving, debounce_timeout.extended, 10);
await clearChat(); await clearChat();
characters[this_chid]['chat'] = file_name; characters[this_chid]['chat'] = file_name;
chat.length = 0; chat.length = 0;

View File

@ -16,6 +16,7 @@ import {
localizePagination, localizePagination,
renderPaginationDropdown, renderPaginationDropdown,
paginationDropdownChangeHandler, paginationDropdownChangeHandler,
waitUntilCondition,
} from './utils.js'; } from './utils.js';
import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from './RossAscends-mods.js'; import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from './RossAscends-mods.js';
import { power_user, loadMovingUIState, sortEntitiesList } from './power-user.js'; import { power_user, loadMovingUIState, sortEntitiesList } from './power-user.js';
@ -1912,6 +1913,7 @@ export async function getGroupPastChats(groupId) {
} }
export async function openGroupChat(groupId, chatId) { export async function openGroupChat(groupId, chatId) {
await waitUntilCondition(() => !isChatSaving, debounce_timeout.extended, 10);
const group = groups.find(x => x.id === groupId); const group = groups.find(x => x.id === groupId);
if (!group || !group.chats.includes(chatId)) { if (!group || !group.chats.includes(chatId)) {