mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-15 18:08:46 +00:00
fixed up add subscription method
This commit is contained in:
parent
c7859e0f0a
commit
f111553827
@ -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
|
||||
|
||||
@ -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 {
|
||||
<p>Loading post...</p>
|
||||
);
|
||||
|
||||
return (
|
||||
authenticated ? (
|
||||
this.state.loading ? (<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>) :
|
||||
<Grid container>
|
||||
<Grid item sm={4} xs={8}>
|
||||
<Writing_Microblogs />
|
||||
return authenticated ? (
|
||||
this.state.loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<Grid container>
|
||||
<Grid item sm={4} xs={8}>
|
||||
<Writing_Microblogs />
|
||||
</Grid>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{postMarkup}
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{postMarkup}
|
||||
</Grid>
|
||||
</Grid>
|
||||
) : loading ?
|
||||
(<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>)
|
||||
:
|
||||
(
|
||||
<div>
|
||||
<div>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<br/><br/>
|
||||
<b>Welcome to Twistter!</b>
|
||||
<br/><br/>
|
||||
<b>See the most interesting topics people are following right now.</b>
|
||||
</div>
|
||||
)
|
||||
) : loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<div>
|
||||
<div>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<br />
|
||||
<br />
|
||||
<b>Welcome to Twistter!</b>
|
||||
<br />
|
||||
<br />
|
||||
<b>See the most interesting topics people are following right now.</b>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<b>Join today or sign in if you already have an account.</b>
|
||||
<br />
|
||||
<br />
|
||||
<form action="./signup">
|
||||
<button className="authButtons signup">Sign up</button>
|
||||
</form>
|
||||
<br />
|
||||
<form action="./login">
|
||||
<button className="authButtons login">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
<div>
|
||||
<b>Join today or sign in if you already have an account.</b>
|
||||
<br />
|
||||
<br />
|
||||
<form action="./signup">
|
||||
<button className="authButtons signup">Sign up</button>
|
||||
</form>
|
||||
<br />
|
||||
<form action="./login">
|
||||
<button className="authButtons login">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
<p>Posts</p>
|
||||
);
|
||||
|
||||
return (
|
||||
this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> :
|
||||
return this.state.loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<Grid container spacing={24}>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{imageMarkup}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user