Deduplicate functionality.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 30 Nov 2010 05:15:33 +0000 (06:15 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 30 Nov 2010 05:15:33 +0000 (06:15 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java

index bdea989..24f1209 100644 (file)
@@ -561,10 +561,9 @@ public class Core implements IdentityListener {
                synchronized (newPosts) {
                        boolean isNew = !knownPosts.contains(postId) && newPosts.contains(postId);
                        if (markAsKnown) {
-                               newPosts.remove(postId);
-                               knownPosts.add(postId);
-                               if (isNew) {
-                                       coreListenerManager.fireMarkPostKnown(getPost(postId));
+                               Post post = getPost(postId, false);
+                               if (post != null) {
+                                       markPostKnown(post);
                                }
                        }
                        return isNew;
@@ -654,10 +653,9 @@ public class Core implements IdentityListener {
                synchronized (newReplies) {
                        boolean isNew = !knownReplies.contains(replyId) && newReplies.contains(replyId);
                        if (markAsKnown) {
-                               newReplies.remove(replyId);
-                               knownReplies.add(replyId);
-                               if (isNew) {
-                                       coreListenerManager.fireMarkReplyKnown(getReply(replyId));
+                               Reply reply = getReply(replyId, false);
+                               if (reply != null) {
+                                       markReplyKnown(reply);
                                }
                        }
                        return isNew;