From edc855dd691b472f36007fc8492e0f70e3301c60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Jan 2011 15:05:07 +0100 Subject: [PATCH] =?utf8?q?Add=20more=20information=20to=20new=20reply=20in?= =?utf8?q?formation=20and=20don=E2=80=99t=20load=20replies=20if=20obviousl?= =?utf8?q?y=20not=20necessary.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java | 7 ++++++- src/main/resources/static/javascript/sone.js | 9 ++++++--- 2 files changed, 12 insertions(+), 4 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 effbebe..172f237 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -101,7 +101,12 @@ public class GetStatusAjaxPage extends JsonPage { Set newReplies = webInterface.getNewReplies(); JsonArray jsonReplies = new JsonArray(); for (Reply reply : newReplies) { - jsonReplies.add(reply.getId()); + JsonObject jsonReply = new JsonObject(); + jsonReply.put("id", reply.getId()); + jsonReply.put("sone", reply.getSone().getId()); + jsonReply.put("post", reply.getPost().getId()); + jsonReply.put("postSone", reply.getPost().getSone().getId()); + jsonReplies.add(jsonReply); } return createSuccessJsonObject().put("sones", jsonSones).put("notifications", jsonNotifications).put("removedNotifications", jsonRemovedNotifications).put("newPosts", jsonPosts).put("newReplies", jsonReplies); } diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 70d124e..ca087fa 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -453,7 +453,7 @@ function ajaxifyPost(postElement) { postReply(postId, text, function(success, error, replyId) { if (success) { $(inputField).val(""); - loadNewReply(replyId); + loadNewReply(replyId, getCurrentSoneId(), postId); markPostAsKnown(getPostElement(inputField)); $("#sone .post#" + postId + " .create-reply").addClass("hidden"); } else { @@ -589,7 +589,7 @@ function getStatus() { }); /* process new replies. */ $.each(data.newReplies, function(index, value) { - loadNewReply(value); + loadNewReply(value.id, value.sone, value.post, value.postSone); }); /* do it again in 5 seconds. */ setTimeout(getStatus, 5000); @@ -745,10 +745,13 @@ function loadNewPost(postId, soneId, recipientId) { }); } -function loadNewReply(replyId) { +function loadNewReply(replyId, soneId, postId, postSoneId) { if (hasReply(replyId)) { return; } + if (!hasPost(postId)) { + return; + } $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) { /* find post. */ if ((data != null) && data.success) { -- 2.7.4