Set<Reply> 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);
}
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 {
});
/* 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);
});
}
-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) {