aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-01 19:18:03 +0300
committerGravatar Vitaly Takmazov2018-03-01 19:49:10 +0300
commit70a50b2252ed313e3aee1a9ee2f33be8a46cb028 (patch)
treecf1f15f826ef21f2f431e242b9db50b9bcbf3dbf /juick-www/src/main/java/com/juick/www/controllers
parentf92fb49bfab851d6de2480cf0359920516bfe050 (diff)
sort discussions by last replay date
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/Messages.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/Messages.java b/juick-www/src/main/java/com/juick/www/controllers/Messages.java
index e74f7486..c83bb356 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/Messages.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/Messages.java
@@ -41,6 +41,9 @@ import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.URLEncoder;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BooleanSupplier;
@@ -117,6 +120,7 @@ public class Messages {
@RequestParam(name = "show", required = false) String paramShow,
@RequestParam(name = "search", required = false) String paramSearch,
@RequestParam(name = "before", required = false, defaultValue = "0") Integer paramBefore,
+ @RequestParam(name = "to", required = false, defaultValue = "0") Long paramTo,
@CookieValue(name = "sape_cookie", required = false, defaultValue = StringUtils.EMPTY) String sapeCookie,
ModelMap model) throws IOException {
if (tag != null) {
@@ -156,7 +160,7 @@ public class Messages {
mids = messagesService.getPrivate(visitor.getUid(), paramBefore);
} else if (paramShow.equals("discuss") && !visitor.isAnonymous()) {
title = "Обсуждения";
- mids = messagesService.getDiscussions(visitor.getUid(), paramBefore);
+ mids = messagesService.getDiscussions(visitor.getUid(), paramTo);
} else if (paramShow.equals("recommended") && !visitor.isAnonymous()) {
title = "Рекомендации";
mids = messagesService.getRecommended(visitor.getUid(), paramBefore);
@@ -194,7 +198,7 @@ public class Messages {
model.addAttribute("showAdv",
paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUid() == 0);
if (mids.size() >= 20) {
- String nextpage = "?before=" + mids.get(mids.size() - 1);
+ String nextpage = (paramShow != null && paramShow.equals("discuss")) ? "?to=" + msgs.get(msgs.size() - 1).getUpdated().toEpochMilli() : "?before=" + mids.get(mids.size() - 1);
if (paramShow != null) {
nextpage += "&show=" + paramShow;
}