Also react correctly on a “view Sone” page.
[Sone.git] / src / main / resources / static / javascript / sone.js
index c9521b7..70d124e 100644 (file)
@@ -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) {
@@ -872,7 +876,7 @@ $(document).ready(function() {
                        text = $(this).find(":input:enabled").val();
                        $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {
-                                       loadNewPost(data.postId);
+                                       loadNewPost(data.postId, getCurrentSoneId());
                                }
                        });
                        $(this).find(":input:enabled").val("").blur();
@@ -887,7 +891,7 @@ $(document).ready(function() {
                        text = $(this).find(":input:enabled").val();
                        $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {
-                                       loadNewPost(data.postId);
+                                       loadNewPost(data.postId, getCurrentSoneId());
                                }
                        });
                        $(this).find(":input:enabled").val("").blur();