From 62dc486c8577bef6d0c65fd3777b9425bd85a06d Mon Sep 17 00:00:00 2001 From: Aryan Kothari <87589047+thearyadev@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:19:14 -0400 Subject: [PATCH] add: add paginated scroll handler --- src/lib/components/layout/Sidebar.svelte | 77 +++++++++++++++++++++--- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 49a0e2ebb..d8434e6a2 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -11,7 +11,10 @@ showSidebar, mobile, showArchivedChats, - pinnedChats + pinnedChats, + pageSkip, + pageLimit, + scrollPaginationEnabled } from '$lib/stores'; import { onMount, getContext, tick } from 'svelte'; @@ -49,6 +52,12 @@ let showDropdown = false; let filteredChatList = []; + let paginationScrollThreashold = 0.6; + let nextPageLoading = false; + let tagView = false; + let chatPagniationComplete = false; + + pageLimit.set(20); $: filteredChatList = $chats.filter((chat) => { if (search === '') { @@ -84,7 +93,7 @@ showSidebar.set(window.innerWidth > BREAKPOINT); await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned')); - await chats.set(await getChatList(localStorage.token)); + await chats.set(await getChatList(localStorage.token, $pageSkip, $pageLimit)); let touchstart; let touchend; @@ -185,7 +194,9 @@ await tick(); goto('/'); } - await chats.set(await getChatList(localStorage.token)); + await chats.set( + await getChatList(localStorage.token, 0, $pageSkip * $pageLimit || $pageLimit) + ); await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned')); } }; @@ -235,6 +246,9 @@ ? '' : 'invisible'}" > +