From d2eb3f68749eb6909e6be3647dfab3317a4a5022 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 26 Nov 2011 01:39:32 +0100 Subject: [PATCH] Sort notifications before handing them out. --- src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java | 2 ++ .../java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 3218b58..b0d31d2 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -262,6 +263,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); List notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone); + Collections.sort(notifications, Notification.CREATED_TIME_SORTER); templateContext.set("notifications", notifications); templateContext.set("notificationHash", HashCode.hashCode(notifications)); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java index d0020ca..d88aae9 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java @@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax; import java.io.IOException; import java.io.StringWriter; import java.util.Collection; +import java.util.Collections; import java.util.List; import net.pterodactylus.sone.data.Sone; @@ -79,6 +80,7 @@ public class GetNotificationsAjaxPage extends JsonPage { Sone currentSone = getCurrentSone(request.getToadletContext(), false); Collection notifications = webInterface.getNotifications().getNotifications(); List filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone); + Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER); int notificationHash = HashCode.hashCode(filteredNotifications); JsonArray jsonNotifications = new JsonArray(); for (Notification notification : filteredNotifications) { -- 2.7.4