From 7fa534ddfd44df78abca62b5b81be0cb61c45425 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Fri, 21 Feb 2020 14:01:52 +0100
Subject: [PATCH] If there are no tokens, sort by time

---
 .../comment-settings.component.ts                 | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts
index 87830b91b..51e4354f9 100644
--- a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts
+++ b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts
@@ -119,15 +119,14 @@ export class CommentSettingsComponent implements OnInit {
               return a.bonusToken ? -1 : 1;
             });
             if (!sortedComments[0].bonusToken) {
-              sortedComments = comments.sort((a) => {
-                return a.favorite ? -1 : 1;
+              sortedComments = comments.sort((a, b) => {
+                const dateA = new Date(a.timestamp), dateB = new Date(b.timestamp);
+                return (+dateB > +dateA) ? 1 : (+dateA > +dateB) ? -1 : 0;
+              });
+            } else {
+              sortedComments = sortedComments.sort((a, b) => {
+                return a.bonusToken < b.bonusToken ? -1 : 1;
               });
-              if (!sortedComments[0].favorite) {
-                sortedComments = comments.sort((a, b) => {
-                  const dateA = new Date(a.timestamp), dateB = new Date(b.timestamp);
-                  return (+dateB > +dateA) ? 1 : (+dateA > +dateB) ? -1 : 0;
-                });
-              }
             }
             const exportComments = JSON.parse(JSON.stringify(sortedComments));
             let valueFields = '';
-- 
GitLab