{#if Object.keys(history?.messages ?? {}).length == 0} {:else}
{#key chatId}
{#if messages.at(0)?.parentId !== null} { console.log('visible'); if (!messagesLoading) { loadMoreMessages(); } }} >
Loading...
{/if} {#each messages as message, messageIdx (message.id)} { dispatch('submit', e.detail); }} on:action={async (e) => { if (typeof e.detail === 'string') { await chatActionHandler(chatId, e.detail, message.model, message.id); } else { const { id, event } = e.detail; await chatActionHandler(chatId, id, message.model, message.id, event); } }} on:update={() => { updateChatHistory(); }} on:scroll={() => { if (autoScroll) { const element = document.getElementById('messages-container'); autoScroll = element.scrollHeight - element.scrollTop <= element.clientHeight + 50; setTimeout(() => { scrollToBottom(); }, 100); } }} /> {/each}
{#if bottomPadding}
{/if} {/key}
{/if}