From 80a2e1894c5db29fc9a707f2d2a65eb96e50da99 Mon Sep 17 00:00:00 2001 From: Aditya Sankaran Date: Thu, 5 Dec 2019 19:20:05 -0500 Subject: [PATCH] sorted posts chronologically everywhere --- functions/handlers/post.js | 3 +++ twistter-frontend/src/pages/Home.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index 3fedee9..fbe8436 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -74,6 +74,7 @@ exports.getallPosts = (req, res) => { allPosts.forEach(post => { posts.push(post.data()); }); + posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt)); resolve(); }) .catch(error => { @@ -127,6 +128,7 @@ exports.getAlert = (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() { @@ -154,6 +156,7 @@ exports.getOtherUsersPosts = (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() { diff --git a/twistter-frontend/src/pages/Home.js b/twistter-frontend/src/pages/Home.js index 3f47289..86d362a 100644 --- a/twistter-frontend/src/pages/Home.js +++ b/twistter-frontend/src/pages/Home.js @@ -148,7 +148,7 @@ class Home extends Component { {post.body}
- Topics: {post.microBlogTopics} + Topics: {post.microBlogTopics.join(", ")}