If no current Sone exists, return an error.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / NewPage.java
index c7281e3..7973d28 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - NewPage.java - Copyright © 2012 David Roden
+ * Sone - NewPage.java - Copyright © 2013 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -31,6 +32,8 @@ import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.collect.Collections2;
+
 /**
  * Page that displays all new posts and replies. The posts are filtered using
  * {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)}
@@ -56,17 +59,14 @@ public class NewPage extends SoneTemplatePage {
        // SONETEMPLATEPAGE METHODS
        //
 
-       /**
-        * {@inherit}
-        */
        @Override
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
 
                /* collect new elements from notifications. */
-               Set<Post> posts = webInterface.getNewPosts();
-               for (PostReply reply : webInterface.getNewReplies()) {
-                       posts.add(reply.getPost());
+               Set<Post> posts = new HashSet<Post>(webInterface.getNewPosts());
+               for (PostReply reply : Collections2.filter(webInterface.getNewReplies(), PostReply.HAS_POST_FILTER)) {
+                       posts.add(reply.getPost().get());
                }
 
                /* filter and sort them. */