Skip to content

Commit 2fef289

Browse files
authored
Fix/pictique infinite scrolling mobile (#660)
* Refactor layout structure to include MainPanel component across various protected routes; enhance user experience with consistent UI elements and improved comment handling in home and messages sections. * fix: update route checks in Header component and adjust layout grid for consistency * fix: message input in comment drawer on mobile * refactor: streamline comment handling and enhance error management in home page * fix: improve infinite scrolling behavior on mobile by adjusting scroll container and loading indicators * coderabbitai: fix tailwind class * fix: remove unnecessary console logs from sentinel intersection handling * test: signed commit * test: signed commit 2
1 parent 10d346c commit 2fef289

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

platforms/pictique/src/lib/ui/Avatar/Avatar.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
hasError = true;
3030
img = '/images/user.png';
3131
}
32-
33-
$inspect(img);
3432
</script>
3533

3634
{#if hasError || !img}

platforms/pictique/src/routes/(protected)/home/+page.svelte

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
let isDrawerOpen = $state(false);
3232
3333
const sentinel = (node: HTMLElement) => {
34+
// The sentinel is a direct child of the scrollable ul
35+
const scrollContainer = node.parentElement;
36+
3437
const observer = new IntersectionObserver(
3538
(entries) => {
3639
for (const entry of entries) {
@@ -40,12 +43,16 @@
4043
const loadingMore = get(isLoadingMore);
4144
4245
if (hasMorePosts && !loading && !loadingMore) {
46+
console.log('Triggering loadMoreFeed');
4347
loadMoreFeed();
4448
}
4549
}
4650
}
4751
},
48-
{ rootMargin: '200px' }
52+
{
53+
root: scrollContainer as HTMLElement,
54+
rootMargin: '200px'
55+
}
4956
);
5057
5158
observer.observe(node);
@@ -115,7 +122,7 @@
115122
</script>
116123

117124
<MainPanel>
118-
<ul class="hide-scrollbar h-screen overflow-auto md:h-dvh">
125+
<ul class="hide-scrollbar h-screen overflow-auto pb-24 md:h-dvh md:pb-0">
119126
{#if $isLoading && $posts.length === 0}
120127
<li class="my-4 text-center">Loading posts...</li>
121128
{:else if $error}
@@ -222,7 +229,12 @@
222229
</li>
223230
{/each}
224231
{#if $isLoadingMore}
225-
<li class="my-4 text-center">Loading more posts...</li>
232+
<li class="my-8 flex flex-col items-center justify-center py-8">
233+
<div
234+
class="mb-3 h-8 w-8 animate-spin rounded-full border-2 border-t-transparent"
235+
></div>
236+
<p class="text-base font-medium text-gray-700">Loading more posts...</p>
237+
</li>
226238
{/if}
227239
{#if !$hasMore && $posts.length > 0 && !$isLoadingMore}
228240
<li class="my-4 text-center text-gray-500">No more posts to load</li>

platforms/pictique/src/routes/(protected)/messages/+page.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
7070
// Trim system message prefix from preview text
7171
let previewText = c.latestMessage?.text ?? 'No message yet';
72-
if (typeof previewText === 'string' && previewText.startsWith('$$system-message$$')) {
72+
if (
73+
typeof previewText === 'string' &&
74+
previewText.startsWith('$$system-message$$')
75+
) {
7376
previewText = previewText.replace('$$system-message$$', '').trim();
7477
}
7578

0 commit comments

Comments
 (0)