Stop polling the library catalog and keep the stage on thumbs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,29 +3,21 @@ import { publicLibrary, publicLibraryPage } from '~/server/utils/library'
|
||||
export default defineEventHandler((event) => {
|
||||
const query = getQuery(event)
|
||||
const light = String(query.light || '') === '1'
|
||||
const full = String(query.full || '') === '1'
|
||||
const limitRaw = query.limit
|
||||
const wantsPage = limitRaw != null && String(limitRaw) !== ''
|
||||
const hasLimit = limitRaw != null && String(limitRaw) !== ''
|
||||
// Default GET /api/library → page helper (limit 50). Opt into full catalog with full=1 or legacy light=1.
|
||||
const wantsFull = full || (light && !hasLimit)
|
||||
|
||||
if (wantsPage) {
|
||||
const page = publicLibraryPage(event, {
|
||||
limit: Number(limitRaw) || 50,
|
||||
if (!wantsFull) {
|
||||
return publicLibraryPage(event, {
|
||||
limit: hasLimit ? Number(limitRaw) || 50 : 50,
|
||||
cursor: String(query.cursor || ''),
|
||||
folderId: String(query.folderId || query.folder || ''),
|
||||
type: String(query.type || query.filter || 'all')
|
||||
})
|
||||
try {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const folderId = page.folders.find(folder => folder.unlocked)?.id
|
||||
void maintainLibrary(owner, folderId).catch(() => null)
|
||||
} catch { /* locked or anonymous */ }
|
||||
return page
|
||||
}
|
||||
|
||||
const library = publicLibrary(event, { light })
|
||||
try {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const folderId = library.folders.find(folder => folder.unlocked)?.id
|
||||
void maintainLibrary(owner, folderId).catch(() => null)
|
||||
} catch { /* locked or anonymous — still return what we can */ }
|
||||
return library
|
||||
// Full catalog path — no thumb prewarm on the request (thumbs build on /thumb hit)
|
||||
return publicLibrary(event, { light: true })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user