diff --git a/src/components/editor-page/document-bar/revisions/revision-list.tsx b/src/components/editor-page/document-bar/revisions/revision-list.tsx index ac3dd0618..52c69d65e 100644 --- a/src/components/editor-page/document-bar/revisions/revision-list.tsx +++ b/src/components/editor-page/document-bar/revisions/revision-list.tsx @@ -11,6 +11,7 @@ import { getAllRevisions } from '../../../../api/revisions' import { useApplicationState } from '../../../../hooks/common/use-application-state' import { ListGroup } from 'react-bootstrap' import { AsyncLoadingBoundary } from '../../../common/async-loading-boundary' +import { DateTime } from 'luxon' export interface RevisionListProps { selectedRevisionId?: number @@ -38,14 +39,20 @@ export const RevisionList: React.FC = ({ selectedRevisionId, if (loading || !revisions) { return null } - return revisions.map((revisionListEntry) => ( - onRevisionSelect(revisionListEntry.id)} - revision={revisionListEntry} - key={revisionListEntry.id} - /> - )) + return revisions + .sort((a, b) => { + const timestampA = DateTime.fromISO(a.createdAt).toSeconds() + const timestampB = DateTime.fromISO(b.createdAt).toSeconds() + return timestampB - timestampA + }) + .map((revisionListEntry) => ( + onRevisionSelect(revisionListEntry.id)} + revision={revisionListEntry} + key={revisionListEntry.id} + /> + )) }, [loading, onRevisionSelect, revisions, selectedRevisionId]) return (