making showMoreMessages async to await event emission
| @@ -1830,7 +1830,7 @@ export async function replaceCurrentChat() { | ||
| 1830 | 1830 | } |
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | export async function showMoreMessages(messagesToLoad = null) { |
| 1834 | 1834 | const firstDisplayedMesId = $('#chat').children('.mes').first().attr('mesid'); |
| 1835 | 1835 | let messageId = Number(firstDisplayedMesId); |
| 1836 | 1836 | let count = messagesToLoad || power_user.chat_truncation || Number.MAX_SAFE_INTEGER; |
| @@ -1861,7 +1861,7 @@ export function showMoreMessages(messagesToLoad = null) { | ||
| 1861 | 1861 | $('#chat').scrollTop(newHeight - prevHeight); |
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | await eventSource.emit(event_types.MORE_MESSAGES_LOADED) |
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | 1867 | export async function printMessages() { |
| @@ -11468,8 +11468,8 @@ jQuery(async function () { | ||
| 11468 | 11468 | $('#avatar-and-name-block').slideToggle(); |
| 11469 | 11469 | }); |
| 11470 | 11470 | |
| 11471 | 11471 | $(document).on('mouseup touchend', '#show_more_messages', async function () => { |
| 11472 | 11472 | await showMoreMessages(); |
| 11473 | 11473 | }); |
| 11474 | 11474 | |
| 11475 | 11475 | $(document).on('click', '.open_characters_library', async function () { |
| @@ -2534,7 +2534,7 @@ async function loadUntilMesId(mesId) { | ||
| 2534 | 2534 | let target; |
| 2535 | 2535 | |
| 2536 | 2536 | while (getFirstDisplayedMessageId() > mesId && getFirstDisplayedMessageId() !== 0) { |
| 2537 | 2537 | await showMoreMessages(); |
| 2538 | 2538 | await delay(1); |
| 2539 | 2539 | target = $('#chat').find(`.mes[mesid=${mesId}]`); |
| 2540 | 2540 | |
| @@ -1968,8 +1968,8 @@ export function initDefaultSlashCommands() { | ||
| 1968 | 1968 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1969 | 1969 | name: 'chat-render', |
| 1970 | 1970 | helpString: 'Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.', |
| 1971 | 1971 | callback: async (args, number) => { |
| 1972 | 1972 | await showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER); |
| 1973 | 1973 | if (isTrueBoolean(String(args?.scroll ?? ''))) { |
| 1974 | 1974 | $('#chat').scrollTop(0); |
| 1975 | 1975 | } |