Merge pull request #111 from ClaytonWWilson/filter_timeli

fixed up add subscription method
This commit is contained in:
Leon Liang 2019-12-05 19:25:44 -05:00 committed by GitHub
commit bb50e0fa5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 65 deletions

View File

@ -1178,8 +1178,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

View File

@ -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>
)
); );
} }
} }

View File

@ -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}