mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +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}`);
|
let userRef = db.doc(`/users/${req.userData.handle}`);
|
||||||
userRef.get().then(doc => {
|
userRef.get().then(doc => {
|
||||||
new_following = doc.data().following;
|
new_following = doc.data().following;
|
||||||
|
const struct = {
|
||||||
|
handle: req.body.following,
|
||||||
|
topics: ["Admin"]
|
||||||
|
}
|
||||||
new_following
|
new_following
|
||||||
? new_following.push(req.body.following)
|
? new_following.push(struct)
|
||||||
: (new_following = req.body.following);
|
: (new_following = req.body.following);
|
||||||
|
|
||||||
// add stuff
|
// add stuff
|
||||||
|
|||||||
@ -45,8 +45,13 @@ class Home extends Component {
|
|||||||
let userPromise = axios
|
let userPromise = axios
|
||||||
.get("/user")
|
.get("/user")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
console.log(res.data.credentials.following);
|
||||||
|
let list = [];
|
||||||
|
res.data.credentials.following.forEach(element => {
|
||||||
|
list.push(element.handle);
|
||||||
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
following: res.data.credentials.following,
|
following: list,
|
||||||
topics: res.data.credentials.followedTopics
|
topics: res.data.credentials.followedTopics
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -66,11 +71,11 @@ class Home extends Component {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false
|
loading: false
|
||||||
|
});
|
||||||
})
|
})
|
||||||
})
|
.catch(error => {
|
||||||
.catch((error) => {
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
})
|
});
|
||||||
|
|
||||||
this.props.getLikes();
|
this.props.getLikes();
|
||||||
}
|
}
|
||||||
@ -187,9 +192,13 @@ class Home extends Component {
|
|||||||
<p>Loading post...</p>
|
<p>Loading post...</p>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return authenticated ? (
|
||||||
authenticated ? (
|
this.state.loading ? (
|
||||||
this.state.loading ? (<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>) :
|
<CircularProgress
|
||||||
|
size={60}
|
||||||
|
style={{ marginTop: "300px" }}
|
||||||
|
></CircularProgress>
|
||||||
|
) : (
|
||||||
<Grid container>
|
<Grid container>
|
||||||
<Grid item sm={4} xs={8}>
|
<Grid item sm={4} xs={8}>
|
||||||
<Writing_Microblogs />
|
<Writing_Microblogs />
|
||||||
@ -198,16 +207,21 @@ class Home extends Component {
|
|||||||
{postMarkup}
|
{postMarkup}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
) : loading ?
|
)
|
||||||
(<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>)
|
) : loading ? (
|
||||||
:
|
<CircularProgress
|
||||||
(
|
size={60}
|
||||||
|
style={{ marginTop: "300px" }}
|
||||||
|
></CircularProgress>
|
||||||
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
<img src={logo} className="app-logo" alt="logo" />
|
||||||
<br/><br/>
|
<br />
|
||||||
|
<br />
|
||||||
<b>Welcome to Twistter!</b>
|
<b>Welcome to Twistter!</b>
|
||||||
<br/><br/>
|
<br />
|
||||||
|
<br />
|
||||||
<b>See the most interesting topics people are following right now.</b>
|
<b>See the most interesting topics people are following right now.</b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -229,7 +243,6 @@ class Home extends Component {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@ class user extends Component {
|
|||||||
following: null,
|
following: null,
|
||||||
posts: null,
|
posts: null,
|
||||||
myTopics: null,
|
myTopics: null,
|
||||||
followingList: null
|
followingList: null,
|
||||||
loading: false
|
loading: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -151,11 +151,10 @@ class user extends Component {
|
|||||||
let userPromise = axios
|
let userPromise = axios
|
||||||
.get("/user")
|
.get("/user")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// console.log(res.data.credentials.following);
|
|
||||||
let list = [];
|
let list = [];
|
||||||
let fol = false;
|
let fol = false;
|
||||||
res.data.credentials.following.forEach(follow => {
|
res.data.credentials.following.forEach(follow => {
|
||||||
console.log(follow);
|
// console.log(follow);
|
||||||
if (this.state.profile === follow.handle) {
|
if (this.state.profile === follow.handle) {
|
||||||
fol = true;
|
fol = true;
|
||||||
list = follow.topics;
|
list = follow.topics;
|
||||||
@ -201,9 +200,9 @@ class user extends Component {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -310,8 +309,12 @@ class user extends Component {
|
|||||||
<p>Posts</p>
|
<p>Posts</p>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return this.state.loading ? (
|
||||||
this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> :
|
<CircularProgress
|
||||||
|
size={60}
|
||||||
|
style={{ marginTop: "300px" }}
|
||||||
|
></CircularProgress>
|
||||||
|
) : (
|
||||||
<Grid container spacing={24}>
|
<Grid container spacing={24}>
|
||||||
<Grid item sm={4} xs={8}>
|
<Grid item sm={4} xs={8}>
|
||||||
{imageMarkup}
|
{imageMarkup}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user