]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Don't add a node if it's already there
authorEvan Prodromou <evan@controlyourself.ca>
Mon, 27 Apr 2009 01:16:09 +0000 (21:16 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Mon, 27 Apr 2009 01:16:09 +0000 (21:16 -0400)
Try not to double-add a node on Ajax submit. Normally not a big deal,
but may happen if the CometPlugin (or in the future Strophe or other
auto-update plugins) is enabled.

js/util.js

index 15a14625c7b5bb643fb4a2031a5e70230ac28b54..f15c4f2bbf1e92f94e9f67af17ba247fb277906f 100644 (file)
@@ -188,11 +188,15 @@ $(document).ready(function(){
                                                                                                            alert(result);
                                                     }
                                                     else {
-                                                                                                           $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
-                                                                                                           $("#notices_primary .notice:first").css({display:"none"});
-                                                                                                           $("#notices_primary .notice:first").fadeIn(2500);
-                                                                                                           NoticeHover();
-                                                                                                           NoticeReply();
+                                                         li = $("li", xml).get(0);
+                                                         id = li.id;
+                                                         if ($("#"+li.id).length == 0) {
+                                                              $("#notices_primary .notices").prepend(document._importNode(li, true));
+                                                              $("#notices_primary .notice:first").css({display:"none"});
+                                                              $("#notices_primary .notice:first").fadeIn(2500);
+                                                              NoticeHover();
+                                                              NoticeReply();
+                                                         }
                                                                                                        }
                                                                                                        $("#notice_data-text").val("");
                                                     counter();