Skip to content

Commit

Permalink
fix(core): add parentId to edit events and update sort events logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Jan 23, 2025
1 parent 1197196 commit 985bfd1
Show file tree
Hide file tree
Showing 3 changed files with 433 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {type EventsObservableValue} from './getInitialFetchEvents'
import {type EditDocumentVersionEvent, type UpdateLiveDocumentEvent} from './types'
import {
addParentToEvents,
sortEvents,
squashLiveEditEvents,
updatePublishedEvents,
updateVersionEvents,
Expand All @@ -29,10 +30,7 @@ export function createEventsObservable({
const documentVariantType = getDocumentVariantType(documentId)
return combineLatest([releases$, events$, remoteEdits$, expandedEvents$]).pipe(
map(([releases, {events, nextCursor, loading, error}, remoteEdits, expandedEvents]) => {
const eventsWithRemoteEdits = [...remoteEdits, ...events, ...expandedEvents].sort(
// Sort by timestamp, newest first
(a, b) => Date.parse(b.timestamp) - Date.parse(a.timestamp),
)
const eventsWithRemoteEdits = sortEvents({remoteEdits, events, expandedEvents})

if (documentVariantType === 'published') {
return {
Expand Down
Loading

0 comments on commit 985bfd1

Please sign in to comment.