Try to prevent insertion of a post or reply multiple times.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 14:10:58 +0000 (15:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 14:10:58 +0000 (15:10 +0100)
src/main/resources/static/javascript/sone.js

index a4ad957..7d7bcb5 100644 (file)
@@ -611,6 +611,10 @@ function loadNewPost(postId) {
        loadedPosts[postId] = true;
        $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) {
                if ((data != null) && data.success) {
+                       /* maybe weird timing stuff ensues. */
+                       if (data.post.id in loadedPosts) {
+                               return;
+                       }
                        var firstOlderPost = null;
                        $("#sone .post").each(function() {
                                if (getPostTime(this) < data.post.time) {
@@ -638,6 +642,10 @@ function loadNewReply(replyId) {
        $.getJSON("ajax/getReply.ajax", { "reply": replyId }, function(data, textStatus) {
                /* find post. */
                if ((data != null) && data.success) {
+                       /* maybe weird timing stuff ensues. */
+                       if (data.reply.id in loadedReplies) {
+                               return;
+                       }
                        $("#sone .post#" + data.reply.postId).each(function() {
                                var firstNewerReply = null;
                                $(this).find(".replies .reply").each(function() {