diff --git a/platforms/pictique/src/routes/(protected)/messages/+page.svelte b/platforms/pictique/src/routes/(protected)/messages/+page.svelte index c0697196..14d95be4 100644 --- a/platforms/pictique/src/routes/(protected)/messages/+page.svelte +++ b/platforms/pictique/src/routes/(protected)/messages/+page.svelte @@ -23,6 +23,7 @@ // Pagination and loading state let isLoading = $state(true); + let isLoadingMore = $state(false); let currentPage = $state(1); let totalPages = $state(1); let totalChats = $state(0); @@ -91,21 +92,14 @@ } } - async function loadNextPage() { - if (hasMorePages && !isLoading) { - await loadMessages(currentPage + 1, true); - } - } - - async function loadPreviousPage() { - if (currentPage > 1 && !isLoading) { - await loadMessages(currentPage - 1, false); - } - } - - async function goToPage(page: number) { - if (page >= 1 && page <= totalPages && !isLoading) { - await loadMessages(page, false); + async function loadMoreMessages() { + if (hasMorePages && !isLoadingMore) { + isLoadingMore = true; + try { + await loadMessages(currentPage + 1, true); + } finally { + isLoadingMore = false; + } } } @@ -287,94 +281,26 @@ /> {/each} - - {#if totalPages > 1} -
- - -
- {#if totalPages <= 7} - {#each Array.from({ length: totalPages }, (_, i) => i + 1) as page} - - {/each} - {:else} - - - - {#if currentPage > 3} - ... - {/if} - - - {#each Array.from({ length: Math.min(3, totalPages - 2) }, (_, i) => { - const start = Math.max(2, currentPage - 1); - return Math.min(start + i, totalPages - 1); - }).filter((page, index, arr) => arr.indexOf(page) === index) as page} - - {/each} - - {#if currentPage < totalPages - 2} - ... - {/if} - - - {#if totalPages > 1} - - {/if} - {/if} -
- + + {#if hasMorePages} +
- Page {currentPage} of {totalPages} • {totalChats} total chats + Showing {messages.length} of {totalChats} chats +
+ {:else if messages.length > 0} +
+ All {totalChats} chats loaded
{/if} {:else if !isLoading}