Filter posts and replies from the future.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / IndexPage.java
index 2d85e02..5f4a4a4 100644 (file)
@@ -25,6 +25,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.util.collection.Pagination;
+import net.pterodactylus.util.filter.Filters;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -73,25 +74,20 @@ public class IndexPage extends SoneTemplatePage {
                                }
                        }
                }
+               allPosts = Filters.filteredList(allPosts, Post.FUTURE_POSTS_FILTER);
                Collections.sort(allPosts, Post.TIME_COMPARATOR);
                Pagination<Post> pagination = new Pagination<Post>(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
                templateContext.set("pagination", pagination);
                templateContext.set("posts", pagination.getItems());
-       }
 
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected void postProcess(Request request, TemplateContext templateContext) {
-               @SuppressWarnings("unchecked")
-               List<Post> posts = (List<Post>) templateContext.get("posts");
-               for (Post post : posts) {
+               /* mark it all as known. */
+               for (Post post : pagination.getItems()) {
                        webInterface.getCore().markPostKnown(post);
                        for (Reply reply : webInterface.getCore().getReplies(post)) {
                                webInterface.getCore().markReplyKnown(reply);
                        }
                }
+
        }
 
 }