From 067d76fecedb79fc2f700983bb5409d30d54700a Mon Sep 17 00:00:00 2001 From: Aryan Kothari <87589047+thearyadev@users.noreply.github.com> Date: Sat, 3 Aug 2024 10:35:13 -0400 Subject: [PATCH] fix: dynamically determine page size - larger screens where chat list (35px*pageSize) is smaller than window.InnerHeight, will not be able to scroll. - performance can dynamically scale, allowing mobile devices to load only what they need. --- src/lib/components/layout/Sidebar.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index d8434e6a2..2d6483898 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -56,8 +56,10 @@ let nextPageLoading = false; let tagView = false; let chatPagniationComplete = false; - - pageLimit.set(20); + // number of chats per page depends on screen size. + // 35px is the height of each chat item. + // load 5 extra chats + pageLimit.set(Math.round(window.innerHeight / 35) + 5); $: filteredChatList = $chats.filter((chat) => { if (search === '') {