Move isLikedPostId from Sone to Post.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / PostAccessor.java
index 9f33779..26a05db 100644 (file)
@@ -17,6 +17,8 @@
 
 package net.pterodactylus.sone.template;
 
+import static com.google.common.collect.FluentIterable.from;
+
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
@@ -24,8 +26,6 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.TemplateContext;
 
-import com.google.common.collect.Collections2;
-
 /**
  * Accessor for {@link Post} objects that adds additional properties:
  * <dl>
@@ -54,12 +54,12 @@ public class PostAccessor extends ReflectionAccessor {
        public Object get(TemplateContext templateContext, Object object, String member) {
                Post post = (Post) object;
                if ("replies".equals(member)) {
-                       return Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER);
+                       return from(post.getReplies()).filter(Reply.FUTURE_REPLY_FILTER).toList();
                } else if (member.equals("likes")) {
-                       return core.getLikes(post);
+                       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")) {