From 9d4f175a49bd82f8aa9cc49ab07f028280078a0b Mon Sep 17 00:00:00 2001 From: Aditya Sankaran Date: Tue, 1 Oct 2019 19:07:57 -0400 Subject: [PATCH] added entering topics field and database call for adding topics when writing microblog --- functions/handlers/post.js | 1 + functions/index.js | 3 ++- twistter-frontend/src/Userline.js | 9 ++++++-- twistter-frontend/src/Writing_Microblogs.js | 25 ++++++++++++++++----- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index d15ea33..20528c0 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -11,6 +11,7 @@ exports.putPost = (req, res) => { createdAt: new Date().toISOString(), likeCount: 0, commentCount: 0, + microBlogTopics: req.body.microBlogTopics }; diff --git a/functions/index.js b/functions/index.js index 6ff3bd3..05f3dd3 100644 --- a/functions/index.js +++ b/functions/index.js @@ -253,7 +253,8 @@ const {putPost, getallPostsforUser} = require('./handlers/post'); app.get('/getallPostsforUser', getallPostsforUser); // Adds one post to the database -app.post('/putPost', fbAuth, putPost); +app.post('/putPost', firebaseAuth, putPost); + exports.api = functions.https.onRequest(app); \ No newline at end of file diff --git a/twistter-frontend/src/Userline.js b/twistter-frontend/src/Userline.js index 51d74f4..e8168ce 100644 --- a/twistter-frontend/src/Userline.js +++ b/twistter-frontend/src/Userline.js @@ -9,7 +9,8 @@ class Userline extends Component { { super(props); this.state = { - microBlogs : [] + microBlogs : [], + } } @@ -21,12 +22,16 @@ class Userline extends Component { const post = res.data; this.setState({microBlogs : post}) - }) + }) + + } render() { + let sortedPosts = []; + return (