diff --git a/functions/handlers/users.js b/functions/handlers/users.js index a4dd1bf..64a6763 100644 --- a/functions/handlers/users.js +++ b/functions/handlers/users.js @@ -1145,8 +1145,12 @@ exports.addSubscription = (req, res) => { let userRef = db.doc(`/users/${req.userData.handle}`); userRef.get().then(doc => { new_following = doc.data().following; + const struct = { + handle: req.body.following, + topics: ["Admin"] + } new_following - ? new_following.push(req.body.following) + ? new_following.push(struct) : (new_following = req.body.following); // add stuff diff --git a/twistter-frontend/src/pages/Home.js b/twistter-frontend/src/pages/Home.js index 3f47289..2fc3726 100644 --- a/twistter-frontend/src/pages/Home.js +++ b/twistter-frontend/src/pages/Home.js @@ -41,12 +41,17 @@ class Home extends Component { }; componentDidMount() { - this.setState({loading: true}); + this.setState({ loading: true }); let userPromise = axios .get("/user") .then(res => { + console.log(res.data.credentials.following); + let list = []; + res.data.credentials.following.forEach(element => { + list.push(element.handle); + }); this.setState({ - following: res.data.credentials.following, + following: list, topics: res.data.credentials.followedTopics }); }) @@ -62,15 +67,15 @@ class Home extends Component { }) .catch(err => console.log(err)); - Promise.all([userPromise, postPromise]) - .then(() => { - this.setState({ - loading: false - }) - }) - .catch((error) => { - console.log(error); - }) + Promise.all([userPromise, postPromise]) + .then(() => { + this.setState({ + loading: false + }); + }) + .catch(error => { + console.log(error); + }); this.props.getLikes(); } @@ -187,49 +192,57 @@ class Home extends Component {

Loading post...

); - return ( - authenticated ? ( - this.state.loading ? () : - - - + return authenticated ? ( + this.state.loading ? ( + + ) : ( + + + + + + {postMarkup} + - - {postMarkup} - - - ) : loading ? - () - : - ( -
-
- logo -

- Welcome to Twistter! -

- See the most interesting topics people are following right now. -
+ ) + ) : loading ? ( + + ) : ( +
+
+ logo +
+
+ Welcome to Twistter! +
+
+ See the most interesting topics people are following right now. +
-
-
-
-
+
+
+
+
-
- Join today or sign in if you already have an account. -
-
-
- -
-
-
- -
-
-
- ) +
+ Join today or sign in if you already have an account. +
+
+
+ +
+
+
+ +
+
+
); } } diff --git a/twistter-frontend/src/pages/otherUser.js b/twistter-frontend/src/pages/otherUser.js index 99b26a1..3832b8c 100644 --- a/twistter-frontend/src/pages/otherUser.js +++ b/twistter-frontend/src/pages/otherUser.js @@ -79,7 +79,7 @@ class user extends Component { following: null, posts: null, myTopics: null, - followingList: null + followingList: null, loading: false }; } @@ -135,7 +135,7 @@ class user extends Component { }; componentDidMount() { - this.setState({loading: true}); + this.setState({ loading: true }); let otherUserPromise = axios .post("/getUserDetails", { handle: this.state.profile @@ -151,11 +151,10 @@ class user extends Component { let userPromise = axios .get("/user") .then(res => { - // console.log(res.data.credentials.following); let list = []; let fol = false; res.data.credentials.following.forEach(follow => { - console.log(follow); + // console.log(follow); if (this.state.profile === follow.handle) { fol = true; list = follow.topics; @@ -196,14 +195,14 @@ class user extends Component { .catch(function(err) { console.log(err); }); - - Promise.all([otherUserPromise, userPromise, posts]) - .then(() => { - this.setState({loading: false}); - }) - .catch((error) => { - console.log(error); - }) + + Promise.all([otherUserPromise, userPromise, posts]) + .then(() => { + this.setState({ loading: false }); + }) + .catch(error => { + console.log(error); + }); } render() { @@ -310,8 +309,12 @@ class user extends Component {

Posts

); - return ( - this.state.loading ? : + return this.state.loading ? ( + + ) : ( {imageMarkup}