X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetNotificationsAjaxPage.java;h=65d3943989d3a956b4eba9a3a17a877503ade5e8;hp=e8107ef1b76245e2be6426562c438d98076be51c;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=7017646bf42cb265b6df539bb6def40b91d2f968 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 e8107ef..65d3943 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetNotificationsAjaxPage.java - Copyright © 2011–2013 David Roden + * Sone - GetNotificationsAjaxPage.java - Copyright © 2011–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,13 +21,12 @@ import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance; import java.io.IOException; import java.io.StringWriter; -import java.util.Collection; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.main.SonePlugin; -import net.pterodactylus.sone.notify.ListNotificationFilters; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.notify.Notification; @@ -81,14 +80,13 @@ public class GetNotificationsAjaxPage extends JsonPage { @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { Sone currentSone = getCurrentSone(request.getToadletContext(), false); - Collection notifications = webInterface.getNotifications().getNotifications(); - List filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone); - Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER); + List notifications = new ArrayList(webInterface.getNotifications(currentSone)); + Collections.sort(notifications, Notification.CREATED_TIME_SORTER); ArrayNode jsonNotifications = new ArrayNode(instance); - for (Notification notification : filteredNotifications) { + for (Notification notification : notifications) { jsonNotifications.add(createJsonNotification(request, notification)); } - return createSuccessJsonObject().put("notificationHash", filteredNotifications.hashCode()).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone)); + return createSuccessJsonObject().put("notificationHash", notifications.hashCode()).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone)); } // @@ -115,7 +113,7 @@ public class GetNotificationsAjaxPage extends JsonPage { templateContext.set("currentSone", webInterface.getCurrentSone(request.getToadletContext(), false)); templateContext.set("localSones", webInterface.getCore().getLocalSones()); templateContext.set("request", request); - templateContext.set("currentVersion", SonePlugin.VERSION); + templateContext.set("currentVersion", SonePlugin.getPluginVersion()); templateContext.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion()); templateContext.set("latestEdition", webInterface.getCore().getUpdateChecker().getLatestEdition()); templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); @@ -147,9 +145,9 @@ public class GetNotificationsAjaxPage extends JsonPage { private static JsonNode createJsonOptions(Sone currentSone) { ObjectNode options = new ObjectNode(instance); if (currentSone != null) { - options.put("ShowNotification/NewSones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get()); - options.put("ShowNotification/NewPosts", currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").get()); - options.put("ShowNotification/NewReplies", currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").get()); + options.put("ShowNotification/NewSones", currentSone.getOptions().isShowNewSoneNotifications()); + options.put("ShowNotification/NewPosts", currentSone.getOptions().isShowNewPostNotifications()); + options.put("ShowNotification/NewReplies", currentSone.getOptions().isShowNewReplyNotifications()); } return options; }