Don’t use the ID from the closure, it might have changed its value.
[Sone.git] / src / main / resources / static / javascript / sone.js
index 69c11e0..a042196 100644 (file)
@@ -677,9 +677,12 @@ function loadNewPost(postId) {
        if (postId in loadedPosts) {
                return;
        }
-       loadedPosts[postId] = true;
        $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) {
                if ((data != null) && data.success) {
+                       if (data.post.id in loadedPosts) {
+                               return;
+                       }
+                       loadedPosts[data.post.id] = true;
                        if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) {
                                return;
                        }
@@ -707,10 +710,13 @@ function loadNewReply(replyId) {
        if (replyId in loadedReplies) {
                return;
        }
-       loadedReplies[replyId] = true;
        $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) {
                /* find post. */
                if ((data != null) && data.success) {
+                       if (data.reply.id in loadedReplies) {
+                               return;
+                       }
+                       loadedReplies[data.reply.id] = true;
                        $("#sone .post#" + data.reply.postId).each(function() {
                                var firstNewerReply = null;
                                $(this).find(".replies .reply").each(function() {