projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1446a44
)
Rename comparator for posts
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 20 Oct 2016 17:22:07 +0000
(19:22 +0200)
committer
David ‘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
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Post.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/IndexPage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/NewPage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java
b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java
index
7cea6fd
..
26135ea
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/SoneInserter.java
+++ b/
src/main/java/net/pterodactylus/sone/core/SoneInserter.java
@@
-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("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()));
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()));
diff --git
a/src/main/java/net/pterodactylus/sone/data/Post.java
b/src/main/java/net/pterodactylus/sone/data/Post.java
index
990e20d
..
5a1c2c5
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Post.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Post.java
@@
-33,7
+33,7
@@
import com.google.common.base.Predicate;
public interface Post extends Identified {
/** Comparator for posts, sorts descending by time. */
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) {
@Override
public int compare(Post leftPost, Post rightPost) {
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
b/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
index
8a6dd80
..
04a5bcc
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
@@
-368,7
+368,7
@@
public class SoneImpl implements Sone {
synchronized (this) {
sortedPosts = new ArrayList<Post>(posts);
}
synchronized (this) {
sortedPosts = new ArrayList<Post>(posts);
}
- Collections.sort(sortedPosts, Post.
TIME_COMPARATOR
);
+ Collections.sort(sortedPosts, Post.
NEWEST_FIRST
);
return sortedPosts;
}
return sortedPosts;
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
index
bbff5ed
..
dea5156
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
@@
-74,7
+74,7
@@
public class GetPostFeedCommand extends AbstractSoneCommand {
allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
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));
if (sortedPosts.size() < startPost) {
return new Response("PostFeed", encodePosts(Collections.<Post> emptyList(), "Posts.", false));
diff --git
a/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
b/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
index
d4b8980
..
b273bdb
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
@@
-71,7
+71,7
@@
public class BookmarksPage extends SoneTemplatePage {
}
});
List<Post> sortedPosts = new ArrayList<Post>(loadedPosts);
}
});
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());
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());
diff --git
a/src/main/java/net/pterodactylus/sone/web/IndexPage.java
b/src/main/java/net/pterodactylus/sone/web/IndexPage.java
index
030ec3d
..
1d40f45
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/IndexPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/IndexPage.java
@@
-78,7
+78,7
@@
public class IndexPage extends SoneTemplatePage {
}
allPosts = Collections2.filter(allPosts, postVisibilityFilter.isVisible(currentSone));
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
}
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());
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());
diff --git
a/src/main/java/net/pterodactylus/sone/web/NewPage.java
b/src/main/java/net/pterodactylus/sone/web/NewPage.java
index
133a9d1
..
406054d
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/NewPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/NewPage.java
@@
-71,7
+71,7
@@
public class NewPage extends SoneTemplatePage {
/* filter and sort them. */
List<Post> sortedPosts = new ArrayList(posts);
/* 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));
/* paginate them. */
Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
diff --git
a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
index
119456f
..
f2c9c91
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
@@
-90,7
+90,7
@@
public class ViewSonePage extends SoneTemplatePage {
}
List<Post> sonePosts = sone.get().getPosts();
sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
}
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());
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());