diff --git a/app/src/components/VideoPlayer.js b/app/src/components/VideoPlayer.js
index 8edfdcd7..33f35af6 100644
--- a/app/src/components/VideoPlayer.js
+++ b/app/src/components/VideoPlayer.js
@@ -153,16 +153,22 @@ const Comments = ({comments, video}) => {
const rootComments = comments.filter(i => i['parent'] === 'root');
- const sortedByParent = {};
+ // Comments are in an array, convert it to a dict, grouped by their parent.
+ const groupedByParent = {};
comments.forEach(obj => {
- if (!sortedByParent[obj.parent]) {
- sortedByParent[obj.parent] = [];
+ if (!groupedByParent[obj.parent]) {
+ groupedByParent[obj.parent] = [];
}
- sortedByParent[obj.parent].push(obj);
+ groupedByParent[obj.parent].push(obj);
+ })
+ // Sort replies to each parent by the time they were created.
+ comments.forEach(obj => {
+ const children = groupedByParent[obj.parent];
+ groupedByParent[obj.parent] = _.sortBy(children, ['timestamp']);
})
return
- {rootComments.map((i, key) => )}
+ {rootComments.map((i, key) => )}
}
@@ -350,7 +356,7 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {