making showMoreMessages async to await event emission

This commit is contained in:
qvink
2025-01-22 08:36:47 -07:00
parent 1641b1f91f
commit f1923c5364
3 changed files with 7 additions and 7 deletions

View File

@ -1830,7 +1830,7 @@ export async function replaceCurrentChat() {
} }
} }
export function showMoreMessages(messagesToLoad = null) { export async function showMoreMessages(messagesToLoad = null) {
const firstDisplayedMesId = $('#chat').children('.mes').first().attr('mesid'); const firstDisplayedMesId = $('#chat').children('.mes').first().attr('mesid');
let messageId = Number(firstDisplayedMesId); let messageId = Number(firstDisplayedMesId);
let count = messagesToLoad || power_user.chat_truncation || Number.MAX_SAFE_INTEGER; let count = messagesToLoad || power_user.chat_truncation || Number.MAX_SAFE_INTEGER;
@ -1861,7 +1861,7 @@ export function showMoreMessages(messagesToLoad = null) {
$('#chat').scrollTop(newHeight - prevHeight); $('#chat').scrollTop(newHeight - prevHeight);
} }
eventSource.emit(event_types.MORE_MESSAGES_LOADED) await eventSource.emit(event_types.MORE_MESSAGES_LOADED)
} }
export async function printMessages() { export async function printMessages() {
@ -11468,8 +11468,8 @@ jQuery(async function () {
$('#avatar-and-name-block').slideToggle(); $('#avatar-and-name-block').slideToggle();
}); });
$(document).on('mouseup touchend', '#show_more_messages', () => { $(document).on('mouseup touchend', '#show_more_messages', async function () {
showMoreMessages(); await showMoreMessages();
}); });
$(document).on('click', '.open_characters_library', async function () { $(document).on('click', '.open_characters_library', async function () {

View File

@ -2534,7 +2534,7 @@ async function loadUntilMesId(mesId) {
let target; let target;
while (getFirstDisplayedMessageId() > mesId && getFirstDisplayedMessageId() !== 0) { while (getFirstDisplayedMessageId() > mesId && getFirstDisplayedMessageId() !== 0) {
showMoreMessages(); await showMoreMessages();
await delay(1); await delay(1);
target = $('#chat').find(`.mes[mesid=${mesId}]`); target = $('#chat').find(`.mes[mesid=${mesId}]`);

View File

@ -1968,8 +1968,8 @@ export function initDefaultSlashCommands() {
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'chat-render', name: 'chat-render',
helpString: 'Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.', helpString: 'Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.',
callback: (args, number) => { callback: async (args, number) => {
showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER); await showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER);
if (isTrueBoolean(String(args?.scroll ?? ''))) { if (isTrueBoolean(String(args?.scroll ?? ''))) {
$('#chat').scrollTop(0); $('#chat').scrollTop(0);
} }