Files
supabase/apps/studio/data/storage/versioning/version-order.ts
Tyler HilleryandClaude d7ad2cdb32 fix(studio): order object versions by archived_at (#54104)
## Problem

Object versions are sorted by `created_at`, but a version's `created_at`
doesn't always reflect when it was written. When a bucket is suspended,
an upload replaces the null version in place and keeps that row's
original `created_at`, so the current version can show up below older
ones in the versions panel.

## Solution

Sort by `archived_at`. The current version has no `archived_at`, so it
comes first, followed by the most recently archived.

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-30 12:55:14 +01:00

9 lines
372 B
TypeScript

type ArchivedAt = { archived_at?: string | null }
// A null archived_at marks the key's single current version, so it sorts first.
const archivedTime = (version: ArchivedAt) =>
version.archived_at ? Date.parse(version.archived_at) : Number.MAX_SAFE_INTEGER
export const compareNewestVersionFirst = (a: ArchivedAt, b: ArchivedAt) =>
archivedTime(b) - archivedTime(a)