feat(admin/media): Suche, serverseitiger Filter & Infinite-Scroll-Pagination#16
Open
mrwind-up-bird wants to merge 1 commit into
Open
feat(admin/media): Suche, serverseitiger Filter & Infinite-Scroll-Pagination#16mrwind-up-bird wants to merge 1 commit into
mrwind-up-bird wants to merge 1 commit into
Conversation
…ation
The media library only ever returned the newest 50 items with no way to
reach older media; the Bilder/Videos filter only filtered those 50 and
there was no search box (though the API already accepted ?search=).
- GET /api/admin/media now returns { items, nextCursor, total } with
cursor pagination (orderBy createdAt desc, id desc), server-side search
+ type filter, a clamped limit, withRetry + try/catch, and a count only
on the first page.
- New pure, unit-tested helpers in lib/media-query.ts (parse/validate
query, build where, paginate) — 12 tests.
- Media page: debounced search box, server-side Bilder/Videos filter,
IntersectionObserver infinite scroll (scoped to the <main> scroll
container) with a "Mehr laden" fallback, live total. Cursor is derived
from the last loaded item so deleting the boundary row can't wedge
paging; a generation guard + synchronous reloadingRef drop stale
cross-filter appends; failed loads surface an explicit retry.
- MediaPickerDialog and the slider image search read the new { items }
shape (the only other consumers of the endpoint).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/admin/medialud nur die neuesten 50 Medien und bot keinen Weg zu älteren Dateien. Der Bilder/Videos-Filter filterte nur diese 50, und es gab kein Suchfeld — dadurch waren ältere Medien praktisch unerreichbar.Lösung
Alles serverseitig über die gesamte Bibliothek:
N Dateien,(gefiltert))Änderungen
GET /api/admin/media→{ items, nextCursor, total }mit Cursor-Pagination (orderBy createdAt desc, id desc), serverseitiger Suche + Typ-Filter, geklemmtemlimit,withRetry+ try/catch,countnur auf der ersten Seite.src/lib/media-query.ts— reine, unit-getestete Helfer (parseMediaQuery,buildMediaWhere,paginate), 12 Tests.reloadingRefverwerfen veraltete Cross-Filter-Appends; Observer an den<main>-Scrollcontainer gebunden; fehlgeschlagene Loads bieten explizites „Erneut laden".MediaPickerDialogund die Slider-Bildsuche lesen die neue{ items }-Form (die einzigen weiteren Konsumenten des Endpoints).Reviews
Zwei unabhängige Code-Reviews (Fokus: Cursor-Korrektheit, Observer-Lifecycle, Races). Alle Critical/Important-Findings behoben und verifiziert.
Bekannte, bewusst zurückgestellte Kleinigkeiten (kein Datenverlust):
MediaPickerDialog-Suche läuft weiterhin client-seitig über die erste Seite (Folge-Aufgabe, jetzt wo der API-Endpoint Suche kann).Gates
tsc --noEmitsaubernext builderfolgreich (56/56 Seiten)🤖 Generated with Claude Code