From e3522876d7862175b4a66742953dcca1cb684022 Mon Sep 17 00:00:00 2001 From: Aditya Sankaran Date: Thu, 5 Dec 2019 18:50:29 -0500 Subject: [PATCH] can sort posts chronologically in userline and formatted topics listing for each post --- functions/handlers/post.js | 2 ++ twistter-frontend/src/pages/user.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index 788c64e..da8474f 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -46,8 +46,10 @@ exports.getallPostsforUser = (req, res) => { myPosts.forEach(function(doc) { posts.push(doc.data()); }); + posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt)); return res.status(200).json(posts); }) + .then(function() { return res .status(200) diff --git a/twistter-frontend/src/pages/user.js b/twistter-frontend/src/pages/user.js index 59c096e..b83f55a 100644 --- a/twistter-frontend/src/pages/user.js +++ b/twistter-frontend/src/pages/user.js @@ -230,7 +230,7 @@ class user extends Component { {post.userHandle} - {post.createdAt} + {this.formatDate(post.createdAt) }
@@ -243,7 +243,7 @@ class user extends Component { {post.body}
- Topics: {post.microBlogTopics} + Topics: {post.microBlogTopics.join(", ")}