Remove obsolete “loadAllSones” parameter.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / GetStatusAjaxPage.java
index 1f23e4a..0466098 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - GetStatusAjaxPage.java - Copyright © 2010 David Roden
+ * Sone - GetStatusAjaxPage.java - Copyright © 2010–2012 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
@@ -32,8 +32,8 @@ import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.filter.Filter;
-import net.pterodactylus.util.filter.Filters;
+import net.pterodactylus.util.collection.filter.Filter;
+import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
@@ -66,19 +66,14 @@ public class GetStatusAjaxPage extends JsonPage {
        @Override
        protected JsonObject createJsonObject(FreenetRequest request) {
                final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
-               /* load Sones. */
-               boolean loadAllSones = Boolean.parseBoolean(request.getHttpRequest().getParam("loadAllSones", "false"));
+               /* load Sones. always return the status of the current Sone. */
                Set<Sone> sones = new HashSet<Sone>(Collections.singleton(getCurrentSone(request.getToadletContext(), false)));
-               if (loadAllSones) {
-                       sones.addAll(webInterface.getCore().getSones());
-               } else {
-                       String loadSoneIds = request.getHttpRequest().getParam("soneIds");
-                       if (loadSoneIds.length() > 0) {
-                               String[] soneIds = loadSoneIds.split(",");
-                               for (String soneId : soneIds) {
-                                       /* just add it, we skip null further down. */
-                                       sones.add(webInterface.getCore().getSone(soneId, false));
-                               }
+               String loadSoneIds = request.getHttpRequest().getParam("soneIds");
+               if (loadSoneIds.length() > 0) {
+                       String[] soneIds = loadSoneIds.split(",");
+                       for (String soneId : soneIds) {
+                               /* just add it, we skip null further down. */
+                               sones.add(webInterface.getCore().getSone(soneId, false));
                        }
                }
                JsonArray jsonSones = new JsonArray();
@@ -91,6 +86,7 @@ public class GetStatusAjaxPage extends JsonPage {
                }
                /* load notifications. */
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
+               Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                int notificationHash = HashCode.hashCode(notifications);
                /* load new posts. */
                Set<Post> newPosts = webInterface.getNewPosts();
@@ -177,7 +173,7 @@ public class GetStatusAjaxPage extends JsonPage {
                jsonSone.put("id", sone.getId());
                jsonSone.put("name", SoneAccessor.getNiceName(sone));
                jsonSone.put("local", sone.getInsertUri() != null);
-               jsonSone.put("status", webInterface.getCore().getSoneStatus(sone).name());
+               jsonSone.put("status", sone.getStatus().name());
                jsonSone.put("modified", webInterface.getCore().isModifiedSone(sone));
                jsonSone.put("locked", webInterface.getCore().isLocked(sone));
                jsonSone.put("lastUpdatedUnknown", sone.getTime() == 0);