fix: session history (#1128)

This commit is contained in:
Aman Harwara
2022-06-21 16:56:33 +05:30
committed by GitHub
parent 0075fcd208
commit ee69102001
3 changed files with 7 additions and 5 deletions

View File

@@ -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)
}} }}

View File

@@ -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],
}) })

View File

@@ -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() {