- Collections.sort(allPosts, Post.TIME_COMPARATOR);
- Pagination<Post> pagination = new Pagination<Post>(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
- dataProvider.set("pagination", pagination);
- dataProvider.set("posts", pagination.getItems());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void postProcess(Request request, DataProvider dataProvider) {
- @SuppressWarnings("unchecked")
- List<Post> posts = (List<Post>) dataProvider.get("posts");
- for (Post post : posts) {
- webInterface.getCore().markPostKnown(post);
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
- }
- }
+ allPosts = Collections2.filter(allPosts, postVisibilityFilter.isVisible(currentSone));
+ List<Post> sortedPosts = new ArrayList<Post>(allPosts);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
+ Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
+ templateContext.set("pagination", pagination);
+ templateContext.set("posts", pagination.getItems());