public void like(Sone localSone);
public void unlike(Sone localSone);
+ boolean isLiked(Sone sone);
Set<Sone> getLikes();
List<PostReply> getReplies();
Sone setLikePostIds(Set<String> likedPostIds);
/**
- * Checks whether the given post ID is liked by this Sone.
- *
- * @param postId
- * The ID of the post
- * @return {@code true} if this Sone likes the given post, {@code false}
- * otherwise
- */
- boolean isLikedPostId(String postId);
-
- /**
* Returns the IDs of all liked replies.
*
* @return All liked replies’ IDs
}
@Override
+ public boolean isLiked(Sone sone) {
+ return database.isLiked(this, sone);
+ }
+
+ @Override
public Set<Sone> getLikes() {
return database.getLikes(this);
}
void likePost(Post post, Sone localSone);
void unlikePost(Post post, Sone localSone);
+ boolean isLiked(Post post, Sone sone);
Set<Sone> getLikes(Post post);
}
}
}
+ public boolean isLiked(Post post, Sone sone) {
+ lock.readLock().lock();
+ try {
+ return likedPostsBySone.containsEntry(sone, post);
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
@Override
public Set<Sone> getLikes(Post post) {
lock.readLock().lock();
return post.getLikes();
} else if (member.equals("liked")) {
Sone currentSone = (Sone) templateContext.get("currentSone");
- return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
+ return (currentSone != null) && post.isLiked(currentSone);
} else if (member.equals("new")) {
return !post.isKnown();
} else if (member.equals("bookmarked")) {