Keep fetching library pages after the first 50 so the whole folder is reachable.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-30 00:28:22 -05:00
co-authored by Cursor
parent 17bb42bea4
commit 9481791ac5
4 changed files with 89 additions and 45 deletions
+11 -4
View File
@@ -752,12 +752,18 @@ export function publicLibraryPage(
let start = 0
if (cursor) {
const idx = rows.findIndex(row => `${row.type}:${row.id}` === cursor)
start = idx >= 0 ? idx + 1 : 0
if (cursor.startsWith('offset:')) {
start = Math.max(0, Math.min(rows.length, Number(cursor.slice(7)) || 0))
} else {
const idx = rows.findIndex(row => `${row.type}:${row.id}` === cursor)
// Unknown cursor → end (never restart at 0 or the client loops the first page forever)
start = idx >= 0 ? idx + 1 : rows.length
}
}
const page = rows.slice(start, start + limit)
const last = page[page.length - 1]
const nextCursor = page.length === limit && last ? `${last.type}:${last.id}` : null
const nextStart = start + page.length
const hasMore = nextStart < rows.length
const nextCursor = hasMore ? `offset:${nextStart}` : null
const stillIds = new Set(page.filter(r => r.type === 'still').map(r => r.id))
const clipIdPage = new Set(page.filter(r => r.type === 'clip').map(r => r.id))
@@ -767,6 +773,7 @@ export function publicLibraryPage(
folders,
items: page,
nextCursor,
hasMore,
limit,
stills: catalog.stills
.filter(s => stillIds.has(s.id))