X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetNotificationsAjaxPage.java;h=d86e5a85229b02d38a174025f459042703286717;hb=53a71d1d6b91e4d56af49a06f2e06bc4d11bf3eb;hp=e8107ef1b76245e2be6426562c438d98076be51c;hpb=7017646bf42cb265b6df539bb6def40b91d2f968;p=Sone.git 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..d86e5a8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java @@ -37,6 +37,7 @@ import net.pterodactylus.util.template.TemplateContext; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Optional; /** * AJAX handler to return all current notifications. @@ -80,9 +81,9 @@ public class GetNotificationsAjaxPage extends JsonPage { */ @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { - Sone currentSone = getCurrentSone(request.getToadletContext(), false); + Optional currentSone = getCurrentSone(request.getToadletContext(), false); Collection notifications = webInterface.getNotifications().getNotifications(); - List filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone); + List filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone.orNull()); Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER); ArrayNode jsonNotifications = new ArrayNode(instance); for (Notification notification : filteredNotifications) { @@ -144,12 +145,12 @@ public class GetNotificationsAjaxPage extends JsonPage { * The current Sone (may be {@code null}) * @return The current options */ - private static JsonNode createJsonOptions(Sone currentSone) { + private static JsonNode createJsonOptions(Optional 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()); + if (currentSone.isPresent()) { + options.put("ShowNotification/NewSones", currentSone.get().getOptions().isShowNewSoneNotifications()); + options.put("ShowNotification/NewPosts", currentSone.get().getOptions().isShowNewPostNotifications()); + options.put("ShowNotification/NewReplies", currentSone.get().getOptions().isShowNewReplyNotifications()); } return options; }