mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 22:31:46 +00:00
fix(photos): paginated search with infinite scroll (#613)
Replace bulk-loading all Immich photos (up to 20k) with paginated search: 50 photos per page, automatic infinite scroll via IntersectionObserver. Prevents server blocking on large libraries. - Backend: searchPhotos accepts page/size params, returns hasMore - Frontend: loads 50 at a time, appends on scroll - AbortController cancels in-flight requests on tab switch
This commit is contained in:
@@ -60,10 +60,10 @@ router.get('/browse', authenticate, async (req: Request, res: Response) => {
|
||||
|
||||
router.post('/search', authenticate, async (req: Request, res: Response) => {
|
||||
const authReq = req as AuthRequest;
|
||||
const { from, to } = req.body;
|
||||
const result = await searchPhotos(authReq.user.id, from, to);
|
||||
const { from, to, page, size } = req.body;
|
||||
const result = await searchPhotos(authReq.user.id, from, to, Number(page) || 1, Math.min(Number(size) || 50, 200));
|
||||
if (result.error) return res.status(result.status!).json({ error: result.error });
|
||||
res.json({ assets: result.assets });
|
||||
res.json({ assets: result.assets, hasMore: result.hasMore });
|
||||
});
|
||||
|
||||
// ── Asset Details ──────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user