Cursor-based pagination for /notifications

Switches `listForUser` from page-offset to cursor (`before` param,
opaque base64 of `{ts, id}`) ordered by `(created_at DESC, id DESC)`
for stable pagination even with simultaneous fan-out inserts.

Returns `{ rows, nextCursor }` instead of a bare array. Loader surfaces
`?before=<cursor>` on a "Load older" link at the bottom of the list,
shown only while `nextCursor !== null`. Default page size 50, capped
at 100. Malformed cursors fall back to "start from top" rather than
400ing — opaque cursors should not be a client validation surface.

Spec drift: delta spec adds three pagination scenarios (cursor pages
forward, tie-stable on identical `created_at`, malformed-cursor
graceful fallback). Design doc gets a new decision section explaining
the cursor choice over page-offset and why we don't compute totals.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-26 01:34:41 +02:00
parent 2892cf9360
commit b20c8cca39
9 changed files with 206 additions and 35 deletions

View file

@ -245,6 +245,7 @@ export default {
title: "Benachrichtigungen",
empty: "Noch keine Benachrichtigungen.",
markAllRead: "Alle als gelesen markieren",
loadOlder: "Ältere laden",
someone: "Jemand",
summary: {
followRequestReceived: "{{name}} möchte dir folgen",

View file

@ -245,6 +245,7 @@ export default {
title: "Notifications",
empty: "No notifications yet.",
markAllRead: "Mark all read",
loadOlder: "Load older",
someone: "Someone",
summary: {
followRequestReceived: "{{name}} requested to follow you",