Allow user to configuration the number of posts shown on a page.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / IndexPage.java
index 2d85e02..e675311 100644 (file)
@@ -22,9 +22,9 @@ import java.util.Collections;
 import java.util.List;
 
 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 +73,11 @@ 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));
+               Pagination<Post> pagination = new Pagination<Post>(allPosts, webInterface.getCore().getPreferences().getPostsPerPage()).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) {
-                       webInterface.getCore().markPostKnown(post);
-                       for (Reply reply : webInterface.getCore().getReplies(post)) {
-                               webInterface.getCore().markReplyKnown(reply);
-                       }
-               }
-       }
-
 }