Fix 'new posts' button on search page not loading posts

The button only called window.scrollTo() and relied on the scroll event
listener to auto-flush the stream buffer. This failed when smooth
scrolling didn't fire reliable scroll events (especially on mobile/
Capacitor WebView). Now explicitly calls flushStreamBuffer() on click.
This commit is contained in:
Chad Curtis
2026-03-28 09:51:30 -05:00
parent 7a49e9646c
commit cdf54e9eff
+5 -2
View File
@@ -400,7 +400,7 @@ export function SearchPage() {
? authorPubkeys
: undefined;
const { posts, isLoading: postsLoading, newPostCount } = useStreamPosts(debouncedSearchQuery, {
const { posts, isLoading: postsLoading, newPostCount, flushStreamBuffer } = useStreamPosts(debouncedSearchQuery, {
includeReplies,
mediaType,
language,
@@ -757,7 +757,10 @@ export function SearchPage() {
}}
>
<button
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
onClick={() => {
flushStreamBuffer();
window.scrollTo({ top: 0, behavior: 'smooth' });
}}
className="pointer-events-auto px-4 py-1.5 rounded-full bg-primary text-primary-foreground text-sm font-medium shadow-lg hover:bg-primary/90 transition-colors animate-in fade-in slide-in-from-top-2 duration-300"
>
{newPostCount} new post{newPostCount !== 1 ? 's' : ''}