From 25e7864337a13dc3ceadbee3a7c6dda6b7c1adff Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 4 Sep 2026 22:18:35 -0500 Subject: [PATCH] Sort library collections by newest part activity. Extending a clip bumps the whole family to the top of date sorts on the studio and full library. --- utils/libraryBrowse.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/libraryBrowse.ts b/utils/libraryBrowse.ts index 79fb23d..792e12a 100644 --- a/utils/libraryBrowse.ts +++ b/utils/libraryBrowse.ts @@ -184,6 +184,11 @@ export function familyRootClip(parts: LibraryClip[]): LibraryClip { return chronologicalParts(parts)[0] || parts[0] } +/** Newest part in a family — keeps extended collections at the top of date sorts. */ +export function familyActivityAt(parts: Array<{ createdAt?: number }>) { + return parts.reduce((max, part) => Math.max(max, Number(part.createdAt) || 0), 0) +} + export function familyLongestDuration(parts: LibraryClip[]) { return parts.reduce((max, part) => Math.max(max, Number(part.duration) || 0), 0) } @@ -413,7 +418,7 @@ export function buildLibraryEntries(opts: { : groupClips(clips).map(group => ({ kind: 'clip' as const, key: group.key, - createdAt: group.head.createdAt, + createdAt: familyActivityAt(group.parts), name: collectionTitle(group), group })) @@ -422,7 +427,7 @@ export function buildLibraryEntries(opts: { : groupStills(stills).map(group => ({ kind: 'still' as const, key: group.key, - createdAt: group.head.createdAt, + createdAt: familyActivityAt(group.parts), name: stillCollectionTitle(group), stillGroup: group }))