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