Skip to content

Commit

Permalink
Use comment editing for updated at time for threads (#4787)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalint authored Jan 23, 2024
1 parent 2073ee1 commit 98f45ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions editor/src/core/shared/multiplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ export function getFirstComment(thread: ThreadData<ThreadMetadata>): CommentData
export function sortThreadsByDescendingUpdateTimeInPlace(
threads: Array<ThreadData<ThreadMetadata>>,
) {
function lastModificationDate(t: ThreadData<ThreadMetadata>) {
return t.updatedAt ?? t.createdAt
function lastModifiedAt(t: ThreadData<ThreadMetadata>) {
const commentsUpdatedAt = t.comments.map((c) => (c.editedAt ?? c.createdAt)?.getTime())
return Math.max(...commentsUpdatedAt)
}

threads.sort((t1, t2) => lastModificationDate(t2).getTime() - lastModificationDate(t1).getTime())
threads.sort((t1, t2) => lastModifiedAt(t2) - lastModifiedAt(t1))
}

export function useUpdateRemixSceneRouteInLiveblocks() {
Expand Down

0 comments on commit 98f45ec

Please sign in to comment.