Mark own posts as new to allow retrieval and insertion on all open tabs.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 7 Apr 2011 09:51:44 +0000 (11:51 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 7 Apr 2011 09:51:44 +0000 (11:51 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/resources/static/javascript/sone.js

index ad1b1aa..9fe4a28 100644 (file)
@@ -1470,7 +1470,8 @@ public class Core implements IdentityListener, UpdateListener {
                        posts.put(post.getId(), post);
                }
                synchronized (newPosts) {
-                       knownPosts.add(post.getId());
+                       newPosts.add(post.getId());
+                       coreListenerManager.fireNewPostFound(post);
                }
                sone.addPost(post);
                saveSone(sone);
@@ -1594,7 +1595,8 @@ public class Core implements IdentityListener, UpdateListener {
                        replies.put(reply.getId(), reply);
                }
                synchronized (newReplies) {
-                       knownReplies.add(reply.getId());
+                       newReplies.add(reply.getId());
+                       coreListenerManager.fireNewReplyFound(reply);
                }
                sone.addReply(reply);
                saveSone(sone);
index 21f6803..f167d69 100644 (file)
@@ -1558,9 +1558,6 @@ $(document).ready(function() {
                        sender = $(this).find(":input[name=sender]").val();
                        text = $(this).find(":input[name=text]:enabled").val();
                        $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "sender": sender, "text": text }, function(data, textStatus) {
-                               if ((data != null) && data.success) {
-                                       loadNewPost(data.postId, data.sone, data.recipient);
-                               }
                                button.removeAttr("disabled");
                        });
                        $(this).find(":input[name=sender]").val(getCurrentSoneId());
@@ -1589,11 +1586,7 @@ $(document).ready(function() {
                $("#sone #post-message").submit(function() {
                        sender = $(this).find(":input[name=sender]").val();
                        text = $(this).find(":input[name=text]:enabled").val();
-                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "sender": sender, "text": text }, function(data, textStatus) {
-                               if ((data != null) && data.success) {
-                                       loadNewPost(data.postId, getCurrentSoneId());
-                               }
-                       });
+                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "sender": sender, "text": text });
                        $(this).find(":input[name=sender]").val(getCurrentSoneId());
                        $(this).find(":input[name=text]:enabled").val("").blur();
                        $(this).find(".sender").hide();