diff --git a/functions/handlers/users.js b/functions/handlers/users.js
index ea3dc28..4cd371e 100644
--- a/functions/handlers/users.js
+++ b/functions/handlers/users.js
@@ -333,6 +333,24 @@ exports.getUserDetails = (req, res) => {
});
};
+exports.getAllHandles = (req, res) => {
+ var user_query = admin.firestore().collection("users");
+ user_query.get()
+ .then((allUsers) => {
+ let users = [];
+ allUsers.forEach((user) => {
+ users.push(user.data().handle);
+ });
+ return res.status(200).json(users);
+ })
+ .catch((err) => {
+ return res.status(500).json({
+ message:"Failed to retrieve posts from database.",
+ error: err
+ });
+ });
+};
+
exports.getAuthenticatedUser = (req, res) => {
let credentials = {};
db.doc(`/users/${req.user.handle}`)
diff --git a/functions/index.js b/functions/index.js
index 5aec5f3..dd38877 100644
--- a/functions/index.js
+++ b/functions/index.js
@@ -16,6 +16,7 @@ const {
createDirectMessage,
checkDirectMessagesEnabled,
toggleDirectMessages,
+ getAllHandles,
getUserDetails,
getProfileInfo,
login,
@@ -61,6 +62,10 @@ app.get("/getUser", fbAuth, getUserDetails);
app.post("/getUserDetails", fbAuth, getUserDetails);
+// Returns a list of all usernames
+// Used for searching
+app.get("/getAllHandles", fbAuth, getAllHandles);
+
// Returns all profile data of the currently logged in user
app.get("/getProfileInfo", fbAuth, getProfileInfo);
diff --git a/twistter-frontend/package.json b/twistter-frontend/package.json
index 71305b9..daf9b48 100644
--- a/twistter-frontend/package.json
+++ b/twistter-frontend/package.json
@@ -11,11 +11,13 @@
"clsx": "^1.0.4",
"create-react-app": "^3.1.2",
"dayjs": "^1.8.17",
+ "fuse.js": "^3.4.6",
"install": "^0.13.0",
"jwt-decode": "^2.2.0",
"node-pre-gyp": "^0.13.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
+ "react-modal": "^3.11.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.0",
"react-scripts": "0.9.5",
diff --git a/twistter-frontend/src/Writing_Microblogs.js b/twistter-frontend/src/Writing_Microblogs.js
index 9cac7b7..4d7484d 100644
--- a/twistter-frontend/src/Writing_Microblogs.js
+++ b/twistter-frontend/src/Writing_Microblogs.js
@@ -40,15 +40,28 @@ class Writing_Microblogs extends Component {
};
axios
- .post("/putPost", postData, headers)
+ .post("/putPost", postData, headers) // TODO: add topics
.then(res => {
- alert("Post was shared successfully!");
+ // alert("Post was shared successfully!");
console.log(res.data);
})
.catch(err => {
alert("An error occured.");
console.error(err);
});
+ console.log(postData.microBlogTopics);
+ postData.microBlogTopics.forEach(topic => {
+ axios
+ .post("/putTopic", {
+ following: topic
+ })
+ .then(res => {
+ console.log(res.data);
+ })
+ .catch(err => {
+ console.error(err);
+ });
+ });
event.preventDefault();
this.setState({ value: "", title: "", characterCount: 250, topics: "" });
}
diff --git a/twistter-frontend/src/pages/Home.js b/twistter-frontend/src/pages/Home.js
index 0602a3a..f08543e 100644
--- a/twistter-frontend/src/pages/Home.js
+++ b/twistter-frontend/src/pages/Home.js
@@ -1,13 +1,13 @@
/* eslint-disable */
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import axios from 'axios';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import { connect } from "react-redux";
+import axios from "axios";
// Material UI and React Router
-import Grid from '@material-ui/core/Grid';
-import Card from '@material-ui/core/Card';
-import CardContent from '@material-ui/core/CardContent';
+import Grid from "@material-ui/core/Grid";
+import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
import Typography from "@material-ui/core/Typography";
// component
@@ -31,7 +31,7 @@ class Home extends Component {
console.log(res.data);
this.setState({
posts: res.data
- })
+ });
})
.catch(err => console.log(err));
}
@@ -41,17 +41,22 @@ class Home extends Component {
let authenticated = this.props.user.authenticated;
let username = this.props.user.credentials.handle;
let postMarkup = this.state.posts ? (
- this.state.posts.map(post =>
+ this.state.posts.map(post => (
) :
- (
)
- }
+ {this.state.imageUrl ? (
+
+ ) : (
+
+ )}
+
My Posts
); + )) + ) : ( +Loading post...
+ ); - return ( - authenticated ? + return authenticated ? (No result
- ); + let resultMarkup = this.state.searchResult && this.state.searchResult !== "No Results" ? ( + this.state.searchResult.map(res => +No results
+ ) + : + ( + null + ) return ( -