fix: Fixes wrong header for session note history when offline (#2967)
This commit is contained in:
committed by
GitHub
parent
2c91178a17
commit
308b98db3d
@@ -26,9 +26,24 @@ export const formatDateAsMonthYearString = (date: Date) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getRevisionEntryDate = (entry: RevisionEntry): Date => {
|
||||||
|
const createdAt = (entry as RevisionMetadata).created_at
|
||||||
|
if (createdAt) {
|
||||||
|
return new Date(createdAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
const noteEntry = entry as NoteHistoryEntry
|
||||||
|
|
||||||
|
if (noteEntry.payload.updated_at.getTime() > 0) {
|
||||||
|
return noteEntry.payload.updated_at
|
||||||
|
}
|
||||||
|
|
||||||
|
return noteEntry.payload.created_at
|
||||||
|
}
|
||||||
|
|
||||||
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 RevisionMetadata).created_at ?? (entry as NoteHistoryEntry).payload.updated_at)
|
const entryDate = getRevisionEntryDate(entry)
|
||||||
|
|
||||||
const differenceBetweenDatesInDays = calculateDifferenceBetweenDatesInDays(todayAsDate, entryDate)
|
const differenceBetweenDatesInDays = calculateDifferenceBetweenDatesInDays(todayAsDate, entryDate)
|
||||||
|
|
||||||
@@ -80,9 +95,7 @@ export const sortRevisionListIntoGroups = <EntryType extends RevisionEntry>(revi
|
|||||||
sortedGroups[groupIndex]?.entries?.push(entry)
|
sortedGroups[groupIndex]?.entries?.push(entry)
|
||||||
} else {
|
} else {
|
||||||
addBeforeLastGroup({
|
addBeforeLastGroup({
|
||||||
title: formatDateAsMonthYearString(
|
title: formatDateAsMonthYearString(getRevisionEntryDate(entry)),
|
||||||
new Date((entry as RevisionMetadata).created_at ?? (entry as NoteHistoryEntry).payload.updated_at),
|
|
||||||
),
|
|
||||||
entries: [entry],
|
entries: [entry],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user