diff --git a/functions/handlers/users.js b/functions/handlers/users.js
index b90c7db..8a3e300 100644
--- a/functions/handlers/users.js
+++ b/functions/handlers/users.js
@@ -1178,8 +1178,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 86d362a..ed2ef94 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 ?
- ()
- :
- (
-
-
-

-
-
Welcome to Twistter!
-
-
See the most interesting topics people are following right now.
-
+ )
+ ) : loading ? (
+
+ ) : (
+
+
+

+
+
+
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 546eac3..3832b8c 100644
--- a/twistter-frontend/src/pages/otherUser.js
+++ b/twistter-frontend/src/pages/otherUser.js
@@ -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}