Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/app/api/zaps/history/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,8 +35,8 @@ export async function GET(request: NextRequest) {
.order("created_at", { ascending: false })
.range(offset, offset + limit - 1) as any;

if (!zaps) {
return NextResponse.json({ zaps: [], total: 0 });
if (!zaps || zaps.length === 0) {
return NextResponse.json({ zaps: [], total: count || 0 });
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.

// Fetch profiles for the other party
Expand Down
Loading