making showMoreMessages async to await event emission

f1923c5364d46fd6501e3c43e8697a030d22ef99

qvink <qvink@users.noreply.github.com>

3 files changed, +7 -7Ignore whitespace
public/script.js+4 -4
@@ -1830,7 +1830,7 @@ export async function replaceCurrentChat() {
18301830 }
18311831}
18321832
18331833export async function showMoreMessages(messagesToLoad = null) {
18341834 const firstDisplayedMesId = $('#chat').children('.mes').first().attr('mesid');
18351835 let messageId = Number(firstDisplayedMesId);
18361836 let count = messagesToLoad || power_user.chat_truncation || Number.MAX_SAFE_INTEGER;
@@ -1861,7 +1861,7 @@ export function showMoreMessages(messagesToLoad = null) {
18611861 $('#chat').scrollTop(newHeight - prevHeight);
18621862 }
18631863
18641864 await eventSource.emit(event_types.MORE_MESSAGES_LOADED)
18651865}
18661866
18671867export async function printMessages() {
@@ -11468,8 +11468,8 @@ jQuery(async function () {
1146811468 $('#avatar-and-name-block').slideToggle();
1146911469 });
1147011470
1147111471 $(document).on('mouseup touchend', '#show_more_messages', async function () => {
1147211472 await showMoreMessages();
1147311473 });
1147411474
1147511475 $(document).on('click', '.open_characters_library', async function () {
public/scripts/power-user.js+1 -1
@@ -2534,7 +2534,7 @@ async function loadUntilMesId(mesId) {
25342534 let target;
25352535
25362536 while (getFirstDisplayedMessageId() > mesId && getFirstDisplayedMessageId() !== 0) {
25372537 await showMoreMessages();
25382538 await delay(1);
25392539 target = $('#chat').find(`.mes[mesid=${mesId}]`);
25402540
public/scripts/slash-commands.js+2 -2
@@ -1968,8 +1968,8 @@ export function initDefaultSlashCommands() {
19681968 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
19691969 name: 'chat-render',
19701970 helpString: 'Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.',
19711971 callback: async (args, number) => {
19721972 await showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER);
19731973 if (isTrueBoolean(String(args?.scroll ?? ''))) {
19741974 $('#chat').scrollTop(0);
19751975 }