File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,33 @@ export const state: State = {
8484 return null ;
8585 }
8686
87+ function sortByInsertedAt (
88+ commentA : CommentFragment | null ,
89+ commentB : CommentFragment | null
90+ ) {
91+ if ( ! commentA || ! commentB ) {
92+ return 0 ;
93+ }
94+
95+ const aDate = new Date ( commentA . insertedAt ) ;
96+ const bDate = new Date ( commentB . insertedAt ) ;
97+
98+ if ( aDate > bDate ) {
99+ return 1 ;
100+ }
101+
102+ if ( bDate < aDate ) {
103+ return - 1 ;
104+ }
105+
106+ return 0 ;
107+ }
108+
87109 return {
88110 ...comments [ currentSandbox . id ] [ currentCommentId ] ,
89- comments : comments [ currentSandbox . id ] [ currentCommentId ] . comments . map (
90- commentId => comments [ currentSandbox . id ] [ commentId . id ] || null
91- ) ,
111+ comments : comments [ currentSandbox . id ] [ currentCommentId ] . comments
112+ . map ( commentId => comments [ currentSandbox . id ] [ commentId . id ] || null )
113+ . sort ( sortByInsertedAt ) ,
92114 } ;
93115 } ,
94116 selectedCommentsFilter : CommentsFilterOption . OPEN ,
You can’t perform that action at this time.
0 commit comments