Update Sone on “view Sone” page, too.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 6 May 2011 23:25:33 +0000 (01:25 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 6 May 2011 23:25:33 +0000 (01:25 +0200)
This fixes #156.

src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
src/main/resources/static/javascript/sone.js

index b28b82e..4e2049e 100644 (file)
@@ -66,10 +66,19 @@ public class GetStatusAjaxPage extends JsonPage {
        protected JsonObject createJsonObject(Request request) {
                final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                /* load Sones. */
-               boolean loadAllSones = Boolean.parseBoolean(request.getHttpRequest().getParam("loadAllSones", "true"));
+               boolean loadAllSones = Boolean.parseBoolean(request.getHttpRequest().getParam("loadAllSones", "false"));
                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));
+                               }
+                       }
                }
                JsonArray jsonSones = new JsonArray();
                for (Sone sone : sones) {
index d21e6c6..838b669 100644 (file)
@@ -978,7 +978,7 @@ function checkForRemovedReplies(oldNotification, newNotification) {
 }
 
 function getStatus() {
-       $.getJSON("getStatus.ajax", {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
+       $.getJSON("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
                if ((data != null) && data.success) {
                        /* process Sone information. */
                        $.each(data.sones, function(index, value) {