From 2e84441e6635b42065ef646238a6c95aea207548 Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Mon, 27 Jan 2020 21:04:30 -0500
Subject: Strictly typing websocket forms.

---
 ui/src/components/post.tsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'ui/src/components/post.tsx')

diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index f57d8913..9ea275ce 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -23,6 +23,7 @@ import {
   SearchType,
   SortType,
   SearchForm,
+  GetPostForm,
   SearchResponse,
   GetSiteResponse,
   GetCommunityResponse,
@@ -84,7 +85,10 @@ export class Post extends Component<any, PostState> {
         () => console.log('complete')
       );
 
-    WebSocketService.Instance.getPost(postId);
+    let form: GetPostForm = {
+      id: postId,
+    };
+    WebSocketService.Instance.getPost(form);
   }
 
   componentWillUnmount() {
-- 
cgit v1.2.3


From 8bcf191a1d17e4bda4ea3304efa98855d4c2590b Mon Sep 17 00:00:00 2001
From: D Anzorge <d.anzorge@gmail.com>
Date: Tue, 28 Jan 2020 19:52:28 +0100
Subject: Add sorting by old (date, ascending) to comment frontend

---
 ui/src/components/post.tsx | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'ui/src/components/post.tsx')

diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index 9ea275ce..36621248 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -235,6 +235,18 @@ export class Post extends Component<any, PostState> {
             onChange={linkEvent(this, this.handleCommentSortChange)}
           />
         </label>
+        <label
+          className={`btn btn-sm btn-secondary pointer ${this.state
+            .commentSort === CommentSortType.Old && 'active'}`}
+        >
+          {i18n.t('old')}
+          <input
+            type="radio"
+            value={CommentSortType.Old}
+            checked={this.state.commentSort === CommentSortType.Old}
+            onChange={linkEvent(this, this.handleCommentSortChange)}
+          />
+        </label>
       </div>
     );
   }
@@ -317,6 +329,13 @@ export class Post extends Component<any, PostState> {
           +a.comment.deleted - +b.comment.deleted ||
           b.comment.published.localeCompare(a.comment.published)
       );
+    } else if (this.state.commentSort == CommentSortType.Old) {
+      tree.sort(
+        (a, b) =>
+          +a.comment.removed - +b.comment.removed ||
+          +a.comment.deleted - +b.comment.deleted ||
+          a.comment.published.localeCompare(b.comment.published)
+      );
     } else if (this.state.commentSort == CommentSortType.Hot) {
       tree.sort(
         (a, b) =>
-- 
cgit v1.2.3

