Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow users dev #53

Merged
merged 6 commits into from
Jul 27, 2020
Merged

Follow users dev #53

merged 6 commits into from
Jul 27, 2020

Conversation

ollyplance
Copy link
Collaborator

This PR adds:

  • follow and unfollow buttons for users
  • if user is signed out, will not show buttons
  • communicates with auth and firestore to add and remove users from following array

Something we might want is a map instead of an array. It will improve time complexity for following and unfollowing. However, if a User deletes their account, to remove this account from the following list would be harder. With an array you can use the .where("following", "array-containes", "uid") and get all of the documents very easily? This also is a less common practice though.

@ollyplance ollyplance requested review from ei84136 and ducre11 July 20, 2020 16:36
@ollyplance
Copy link
Collaborator Author

image

image

Copy link
Collaborator

@ei84136 ei84136 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only had one small question but it LGTM

@@ -22,7 +22,8 @@ export class ViewProfilesComponent implements OnInit {
constructor(
public fAuth: AngularFireAuth,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in other files I've noticed that you have private fAuth vs public fAuth here. I'm wondering if they should all be one or the other?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops yes you are right! I totally forgot that I noticed that and should change it. Thank you for pointing it out! I believe that Private vs Public shouldn't actually matter all that much in Typescript, but it is better to be consistent.

@ollyplance ollyplance requested review from kschon and chris-blay July 24, 2020 12:17
Copy link
Collaborator

@chris-blay chris-blay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return false;
}

follow() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These follow() and unfollow() functions seem like good candidates for unit testing coverage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will be sure to make unit testing for them. Thank you!

@@ -18,7 +18,7 @@ export class LoginComponent implements OnInit {
//and there is no user in the database linked to the account
//it will delete the user (in case user refreshes page before
//setting a username but after signing in with Google
constructor(public fAuth: AngularFireAuth, public router: Router) {}
constructor(private fAuth: AngularFireAuth, private router: Router) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really nice to limit visibility as much as possible up front! Thanks for switching a bunch of these away from public

}
}

unfollow() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be a bit cleaner to have one setFollowing(bool) method that had all the storage logic in it, and turn follow() and unfollow() into one-line methods that call setFollowing(true/false).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the idea, it definitely made the readability better and condensed the code.

@ollyplance ollyplance merged commit 3719581 into main Jul 27, 2020
@ollyplance ollyplance linked an issue Jul 28, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow Users
4 participants