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

Friend/Unfriend Command + MePanel Features #68

Merged
merged 17 commits into from Oct 28, 2018

Conversation

cjinting-nus
Copy link

Softfix can be found in MainWindow lines 201 & 205

@cjinting-nus cjinting-nus added type.story A user story priority.high Must do status.complete The pull request is ready to be merged labels Oct 27, 2018
@cjinting-nus cjinting-nus added this to the v1.3 milestone Oct 27, 2018
Copy link

@nianfei97 nianfei97 left a 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:

  1. The method is unnecessary
  2. 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());

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...

Copy link
Author

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

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;

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

Copy link
Author

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;

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)

Copy link
Author

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())) {

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?

  1. Is himself
  2. Is friend
  3. 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());

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) {

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.

@nianfei97 nianfei97 merged commit 0177cea into CS2113-AY1819S1-W13-1:master Oct 28, 2018
@cjinting-nus cjinting-nus deleted the FixSystemTests branch October 28, 2018 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.high Must do status.complete The pull request is ready to be merged type.story A user story
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants