From 694ab9e6059ad2db8e72efc01b9acddf89bb3fa3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 7 May 2011 01:25:33 +0200 Subject: [PATCH] =?utf8?q?Update=20Sone=20on=20=E2=80=9Cview=20Sone?= =?utf8?q?=E2=80=9D=20page,=20too.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes #156. --- .../net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java | 11 ++++++++++- src/main/resources/static/javascript/sone.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java index b28b82e..4e2049e 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -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 sones = new HashSet(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) { diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index d21e6c6..838b669 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -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) { -- 2.7.4