Allow loading all videos at once instead of limiting to 20

Increase the video limit to 1000 and remove pagination, refactoring the data fetching and state management to load all videos at once on the home page.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 2eb1084e-b728-4449-9231-f1665924c8d5
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2eb1084e-b728-4449-9231-f1665924c8d5/5ujAjpj
This commit is contained in:
sebastjanartic 2025-08-28 20:45:10 +00:00
parent 6dfb575232
commit 8d30c2a6f8

View File

@ -23,8 +23,8 @@ export default function Home() {
// Fetch videos with aggressive caching for speed // Fetch videos with aggressive caching for speed
const { data: videosResponse, isLoading, refetch } = useQuery<VideosResponse>({ const { data: videosResponse, isLoading, refetch } = useQuery<VideosResponse>({
queryKey: ["/api/videos", { queryKey: ["/api/videos", {
limit: 20, limit: 1000, // Naloži vse videje naenkrat
offset, offset: 0,
search: searchQuery || undefined search: searchQuery || undefined
}], }],
queryFn: async ({ queryKey }) => { queryFn: async ({ queryKey }) => {
@ -52,25 +52,16 @@ export default function Home() {
// Update videos when new data comes in // Update videos when new data comes in
useEffect(() => { useEffect(() => {
if (videosResponse) { if (videosResponse) {
if (offset === 0) { setAllVideos(videosResponse.videos);
setAllVideos(videosResponse.videos);
} else {
setAllVideos(prev => [...prev, ...videosResponse.videos]);
}
} }
}, [videosResponse, offset]); }, [videosResponse]);
// Reset videos when search changes // Reset videos when search changes
const handleSearch = (query: string) => { const handleSearch = (query: string) => {
setSearchQuery(query); setSearchQuery(query);
setOffset(0);
setAllVideos([]); setAllVideos([]);
}; };
const handleLoadMore = () => {
setOffset(prev => prev + 20);
};
// Only refetch when search changes, not offset (for speed) // Only refetch when search changes, not offset (for speed)
useEffect(() => { useEffect(() => {
if (searchQuery !== undefined) { if (searchQuery !== undefined) {
@ -96,8 +87,8 @@ export default function Home() {
<VideoGrid <VideoGrid
videos={allVideos} videos={allVideos}
isLoading={isLoading} isLoading={isLoading}
hasMore={videosResponse?.hasMore || false} hasMore={false}
onLoadMore={handleLoadMore} onLoadMore={() => {}}
viewMode={viewMode} viewMode={viewMode}
/> />
</main> </main>