Prevent attempts to favourite your own comments.

This commit is contained in:
dosiecki 2015-06-03 03:28:15 -07:00
parent f8faabeef4
commit c3cb3fb081
2 changed files with 19 additions and 14 deletions

View file

@ -122,16 +122,21 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
favouriteContainer.addView(favouriteImage);
}
favouriteIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!Arrays.asList(comment.likingUsers).contains(user.id)) {
FeedUtils.likeComment(story, comment.userId, context);
} else {
FeedUtils.unlikeComment(story, comment.userId, context);
}
}
});
// users cannot fave their own comments. attempting to do so will actually queue a fatally invalid API call
if (TextUtils.equals(comment.userId, user.id)) {
favouriteIcon.setVisibility(View.GONE);
} else {
favouriteIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!Arrays.asList(comment.likingUsers).contains(user.id)) {
FeedUtils.likeComment(story, comment.userId, context);
} else {
FeedUtils.unlikeComment(story, comment.userId, context);
}
}
});
}
}
replyIcon.setOnClickListener(new OnClickListener() {

View file

@ -212,16 +212,16 @@ public class FeedUtils {
triggerSync(context);
}
public static void likeComment(Story story, String commentId, Context context) {
ReadingAction ra = ReadingAction.likeComment(story.id, commentId, story.feedId);
public static void likeComment(Story story, String commentUserId, Context context) {
ReadingAction ra = ReadingAction.likeComment(story.id, commentUserId, story.feedId);
dbHelper.enqueueAction(ra);
ra.doLocal(dbHelper);
NbActivity.updateAllActivities(true);
triggerSync(context);
}
public static void unlikeComment(Story story, String commentId, Context context) {
ReadingAction ra = ReadingAction.unlikeComment(story.id, commentId, story.feedId);
public static void unlikeComment(Story story, String commentUserId, Context context) {
ReadingAction ra = ReadingAction.unlikeComment(story.id, commentUserId, story.feedId);
dbHelper.enqueueAction(ra);
ra.doLocal(dbHelper);
NbActivity.updateAllActivities(true);