fix: session history (#1128)
This commit is contained in:
@@ -37,7 +37,7 @@ const SessionHistoryList: FunctionComponent<Props> = ({ noteHistoryController })
|
||||
{group.entries.map((entry, index) => (
|
||||
<HistoryListItem
|
||||
key={index}
|
||||
isSelected={selectedRevision?.payload.created_at === entry.payload.created_at}
|
||||
isSelected={selectedRevision?.payload.updated_at === entry.payload.updated_at}
|
||||
onClick={() => {
|
||||
selectSessionRevision(entry)
|
||||
}}
|
||||
|
||||
@@ -17,15 +17,16 @@ export type ListGroup<EntryType extends RevisionEntry> = {
|
||||
export type RemoteRevisionListGroup = ListGroup<RevisionListEntry>
|
||||
export type SessionRevisionListGroup = ListGroup<NoteHistoryEntry>
|
||||
|
||||
export const formatDateAsMonthYearString = (date: Date) =>
|
||||
date.toLocaleDateString(undefined, {
|
||||
export const formatDateAsMonthYearString = (date: Date) => {
|
||||
return date.toLocaleDateString(undefined, {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
})
|
||||
}
|
||||
|
||||
export const getGroupIndexForEntry = (entry: RevisionEntry, groups: ListGroup<RevisionEntry>[]) => {
|
||||
const todayAsDate = new Date()
|
||||
const entryDate = new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.created_at)
|
||||
const entryDate = new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.updated_at)
|
||||
|
||||
const differenceBetweenDatesInDays = calculateDifferenceBetweenDatesInDays(todayAsDate, entryDate)
|
||||
|
||||
@@ -78,7 +79,7 @@ export const sortRevisionListIntoGroups = <EntryType extends RevisionEntry>(revi
|
||||
} else {
|
||||
addBeforeLastGroup({
|
||||
title: formatDateAsMonthYearString(
|
||||
new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.created_at),
|
||||
new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.updated_at),
|
||||
),
|
||||
entries: [entry],
|
||||
})
|
||||
|
||||
@@ -174,6 +174,7 @@ export class NoteHistoryController {
|
||||
this.clearSelection()
|
||||
this.setSelectedEntry(entry)
|
||||
this.setSelectedRevision(entry)
|
||||
this.setContentState(RevisionContentState.Loaded)
|
||||
}
|
||||
|
||||
private get flattenedRemoteHistory() {
|
||||
|
||||
Reference in New Issue
Block a user