X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=ca087fadab83f6f8860225f2e126f74bbdec4b65;hb=edc855dd691b472f36007fc8492e0f70e3301c60;hp=dd7b7498833f1032e6d54f1161512deb16d15697;hpb=526050c6695cb5ae76f0fe9b393d3c5d9b5c83db;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index dd7b749..ca087fa 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -453,7 +453,7 @@ function ajaxifyPost(postElement) { 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 { @@ -589,7 +589,7 @@ function getStatus() { }); /* 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); @@ -710,8 +710,12 @@ function loadNewPost(postId, soneId, recipientId) { if (hasPost(postId)) { return; } - if (!isIndexPage() && (!isViewPostPage() || (getShownPostId() != postId))) { - return; + if (!isIndexPage()) { + if (!isViewPostPage() || (getShownPostId() != postId)) { + if (!isViewSonePage() || ((getShownSoneId() != soneId) && (getShownSoneId() != recipientId))) { + return; + } + } } $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { @@ -741,10 +745,13 @@ function loadNewPost(postId, soneId, recipientId) { }); } -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) {