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:
+11
-4
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user