From 6182a5af5640856cdc21ca7cb05fc8d33bb68191 Mon Sep 17 00:00:00 2001 From: Jorel97 <83238249+Jorel97@users.noreply.github.com> Date: Fri, 29 May 2026 12:43:24 -0600 Subject: [PATCH 1/2] fix(zaps): clamp history pagination ranges --- src/app/api/zaps/history/route.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/api/zaps/history/route.ts b/src/app/api/zaps/history/route.ts index 8cde2888..017d4ee8 100644 --- a/src/app/api/zaps/history/route.ts +++ b/src/app/api/zaps/history/route.ts @@ -14,8 +14,13 @@ export async function GET(request: NextRequest) { const url = new URL(request.url); const direction = url.searchParams.get("direction") || "received"; - const limit = Math.min(parseInt(url.searchParams.get("limit") || "50"), 100); - const offset = parseInt(url.searchParams.get("offset") || "0"); + const parsedLimit = parseInt(url.searchParams.get("limit") || "50", 10); + const parsedOffset = parseInt(url.searchParams.get("offset") || "0", 10); + const limit = Number.isFinite(parsedLimit) + ? Math.min(Math.max(parsedLimit, 1), 100) + : 50; + const offset = + Number.isFinite(parsedOffset) && parsedOffset >= 0 ? parsedOffset : 0; const admin = createServiceClient(); const userId = auth.user.id; @@ -30,7 +35,7 @@ export async function GET(request: NextRequest) { .order("created_at", { ascending: false }) .range(offset, offset + limit - 1) as any; - if (!zaps) { + if (!zaps || zaps.length === 0) { return NextResponse.json({ zaps: [], total: 0 }); } From 3cfdb86a38457fc1a75314009ed9c95bf16918dd Mon Sep 17 00:00:00 2001 From: Jorel97 <83238249+Jorel97@users.noreply.github.com> Date: Fri, 29 May 2026 12:47:21 -0600 Subject: [PATCH 2/2] fix(zaps): preserve count for empty history pages --- src/app/api/zaps/history/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/api/zaps/history/route.ts b/src/app/api/zaps/history/route.ts index 017d4ee8..befd8097 100644 --- a/src/app/api/zaps/history/route.ts +++ b/src/app/api/zaps/history/route.ts @@ -36,7 +36,7 @@ export async function GET(request: NextRequest) { .range(offset, offset + limit - 1) as any; if (!zaps || zaps.length === 0) { - return NextResponse.json({ zaps: [], total: 0 }); + return NextResponse.json({ zaps: [], total: count || 0 }); } // Fetch profiles for the other party