X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=b3b8fdc160677c4beb7f8f25ff5f4e6e20fa91e5;hb=cb4a9b2d8e858faa618ffa9d6a032d1ac5f23d8d;hp=1944efef4a8fcc200352ccc17300b8bf148d7a63;hpb=998958fbec4c4ae0aa1b856d031254b84523ab4c;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 1944efe..b3b8fdc 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -449,9 +449,9 @@ function ajaxifyPost(postElement) { inputField = $(this.form).find(":input:enabled").get(0); postId = getPostId(this); text = $(inputField).val(); - $(inputField).val(""); postReply(postId, text, function(success, error, replyId) { if (success) { + $(inputField).val(""); loadNewReply(replyId); markPostAsKnown(getPostElement(inputField)); $("#sone .post#" + postId + " .create-reply").addClass("hidden"); @@ -534,7 +534,7 @@ function ajaxifyReply(replyElement) { /* mark post and all replies as known on click. */ $(replyElement).click(function() { - markPostAsKnown(getPostElement(replyElement)); + markPostAsKnown(getPostElement(this)); }); } @@ -677,10 +677,13 @@ 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 (!isIndexPage() && !(isViewSonePage() && (getShownSoneId() == data.post.sone))) { + if (data.post.id in loadedPosts) { + return; + } + loadedPosts[data.post.id] = true; + if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) { return; } var firstOlderPost = null; @@ -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() { @@ -732,6 +738,7 @@ function loadNewReply(replyId) { ajaxifyReply(newReply); newReply.slideDown(); setActivity(); + return false; }); } });