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.
This commit is contained in:
@@ -184,6 +184,11 @@ export function familyRootClip(parts: LibraryClip[]): LibraryClip {
|
|||||||
return chronologicalParts(parts)[0] || parts[0]
|
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[]) {
|
export function familyLongestDuration(parts: LibraryClip[]) {
|
||||||
return parts.reduce((max, part) => Math.max(max, Number(part.duration) || 0), 0)
|
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 => ({
|
: groupClips(clips).map(group => ({
|
||||||
kind: 'clip' as const,
|
kind: 'clip' as const,
|
||||||
key: group.key,
|
key: group.key,
|
||||||
createdAt: group.head.createdAt,
|
createdAt: familyActivityAt(group.parts),
|
||||||
name: collectionTitle(group),
|
name: collectionTitle(group),
|
||||||
group
|
group
|
||||||
}))
|
}))
|
||||||
@@ -422,7 +427,7 @@ export function buildLibraryEntries(opts: {
|
|||||||
: groupStills(stills).map(group => ({
|
: groupStills(stills).map(group => ({
|
||||||
kind: 'still' as const,
|
kind: 'still' as const,
|
||||||
key: group.key,
|
key: group.key,
|
||||||
createdAt: group.head.createdAt,
|
createdAt: familyActivityAt(group.parts),
|
||||||
name: stillCollectionTitle(group),
|
name: stillCollectionTitle(group),
|
||||||
stillGroup: group
|
stillGroup: group
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user