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
Friend/Unfriend Command + MePanel Features #68
Friend/Unfriend Command + MePanel Features #68
Conversation
sync with upstream
Sync with upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addFriendToPerson
being an empty method seems to either mean:
- The method is unnecessary
- The feature will not work
It could be that I'm reading it wrong too, but I'm not too sure about how this works yet.
Person editedUser = UserStub.getUser(); | ||
editedPerson.getFriends().add(new Friend(UserStub.getUser().getName())); | ||
Person editedUser = model.getUser(); | ||
addFriendToPerson(editedPerson, model.getUser()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, could you run me through what this part of the code does?
addFriendToPerson
seems to be an empty method too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command would add the current User
to the target Person
's friend list and viceversa
Empty method was not cleaned up, was meant to make the code cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's push it to v1.4 then
private final FriendListPredicate friendListPredicate; | ||
|
||
public CombinedFriendPredicate(Predicate<Person> predicate, FriendListPredicate friendListPredicate) { | ||
this.predicate1 = predicate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 1
seems unnecessary here since the differentiation can be seen by explicitly writing this.predicate
vs predicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, thanks Nian Fei
if (predicate1.test(person) && friendListPredicate.test(person)) { | ||
return true; | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably cleaner to have a else
here
Or even return predicate1.test(person) && friendListPredicate.test(person)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, noted
for (Friend friend : friendList) { | ||
if (currentUser.getName().equals(person.getName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only 3 valid cases, right?
- Is himself
- Is friend
- Is not friend
I think it'd be easier to read if you made each of the 3 cases a branch in an if-else
statement instead of returning false
by default
Person editedUser = UserStub.getUser(); | ||
editedPerson.getFriends().add(new Friend(UserStub.getUser().getName())); | ||
Person editedUser = model.getUser(); | ||
addFriendToPerson(editedPerson, model.getUser()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's push it to v1.4 then
requireNonNull(predicate); | ||
otherList.setPredicate(combinedOtherPredicate(predicate, othersPredicateFromPerson(user))); | ||
} | ||
|
||
@Override | ||
public ObservableList<Person> getFriendList(Person person) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I mentioned this #56 as well but in this context it seems weird to have to pass a person to the API method, given that all it should do update the app with the current User
's friend list instead of any other Person
's. Allowing methods to pass any Person
seems to be unsafe if some other method accidently calls it with anyone other than the current User
.
More things to carry to v1.4 I guess.
Softfix can be found in
MainWindow
lines 201 & 205