mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Prevent attempts to favourite your own comments.
This commit is contained in:
parent
f8faabeef4
commit
c3cb3fb081
2 changed files with 19 additions and 14 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue