Rename comparator for posts
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 20 Oct 2016 17:22:07 +0000 (19:22 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 20 Oct 2016 17:22:07 +0000 (19:22 +0200)
src/main/java/net/pterodactylus/sone/core/SoneInserter.java
src/main/java/net/pterodactylus/sone/data/Post.java
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/java/net/pterodactylus/sone/web/NewPage.java
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java

index 7cea6fd..26135ea 100644 (file)
@@ -307,7 +307,7 @@ public class SoneInserter extends AbstractService {
                        soneProperties.put("time", currentTimeMillis());
                        soneProperties.put("requestUri", sone.getRequestUri());
                        soneProperties.put("profile", sone.getProfile());
-                       soneProperties.put("posts", Ordering.from(Post.TIME_COMPARATOR).sortedCopy(sone.getPosts()));
+                       soneProperties.put("posts", Ordering.from(Post.NEWEST_FIRST).sortedCopy(sone.getPosts()));
                        soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies()));
                        soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
                        soneProperties.put("likedReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
index 990e20d..5a1c2c5 100644 (file)
@@ -33,7 +33,7 @@ import com.google.common.base.Predicate;
 public interface Post extends Identified {
 
        /** Comparator for posts, sorts descending by time. */
-       public static final Comparator<Post> TIME_COMPARATOR = new Comparator<Post>() {
+       public static final Comparator<Post> NEWEST_FIRST = new Comparator<Post>() {
 
                @Override
                public int compare(Post leftPost, Post rightPost) {
index 8a6dd80..04a5bcc 100644 (file)
@@ -368,7 +368,7 @@ public class SoneImpl implements Sone {
                synchronized (this) {
                        sortedPosts = new ArrayList<Post>(posts);
                }
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               Collections.sort(sortedPosts, Post.NEWEST_FIRST);
                return sortedPosts;
        }
 
index bbff5ed..dea5156 100644 (file)
@@ -74,7 +74,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand {
                allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
 
                List<Post> sortedPosts = new ArrayList<Post>(allPosts);
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               Collections.sort(sortedPosts, Post.NEWEST_FIRST);
 
                if (sortedPosts.size() < startPost) {
                        return new Response("PostFeed", encodePosts(Collections.<Post> emptyList(), "Posts.", false));
index d4b8980..b273bdb 100644 (file)
@@ -71,7 +71,7 @@ public class BookmarksPage extends SoneTemplatePage {
                        }
                });
                List<Post> sortedPosts = new ArrayList<Post>(loadedPosts);
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               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());
index 030ec3d..1d40f45 100644 (file)
@@ -78,7 +78,7 @@ public class IndexPage extends SoneTemplatePage {
                }
                allPosts = Collections2.filter(allPosts, postVisibilityFilter.isVisible(currentSone));
                List<Post> sortedPosts = new ArrayList<Post>(allPosts);
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               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());
index 133a9d1..406054d 100644 (file)
@@ -71,7 +71,7 @@ public class NewPage extends SoneTemplatePage {
 
                /* filter and sort them. */
                List<Post> sortedPosts = new ArrayList(posts);
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               Collections.sort(sortedPosts, Post.NEWEST_FIRST);
 
                /* paginate them. */
                Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
index 119456f..f2c9c91 100644 (file)
@@ -90,7 +90,7 @@ public class ViewSonePage extends SoneTemplatePage {
                }
                List<Post> sonePosts = sone.get().getPosts();
                sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
-               Collections.sort(sonePosts, Post.TIME_COMPARATOR);
+               Collections.sort(sonePosts, Post.NEWEST_FIRST);
                Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("postPage"), 0));
                templateContext.set("postPagination", postPagination);
                templateContext.set("posts", postPagination.getItems());