Преглед на файлове

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.
Aryan Kothari преди 9 месеца
родител
ревизия
067d76fece
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      src/lib/components/layout/Sidebar.svelte

+ 4 - 2
src/lib/components/layout/Sidebar.svelte

@@ -56,8 +56,10 @@
 	let nextPageLoading = false;
 	let nextPageLoading = false;
 	let tagView = false;
 	let tagView = false;
 	let chatPagniationComplete = 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) => {
 	$: filteredChatList = $chats.filter((chat) => {
 		if (search === '') {
 		if (search === '') {