Link to correct methods in documentation.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index e94924c..565aec4 100644 (file)
@@ -1168,15 +1168,13 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                List<Post> storedPosts = storedSone.getPosts();
                                synchronized (knownPosts) {
                                        for (Post post : sone.getPosts()) {
-                                               post.setSone(storedSone);
+                                               post.setSone(storedSone).setKnown(knownPosts.contains(post.getId()));
                                                if (!storedPosts.contains(post)) {
                                                        if (post.getTime() < getSoneFollowingTime(sone)) {
-                                                               sone.setKnown(true);
                                                                knownPosts.add(post.getId());
                                                        } else if (!knownPosts.contains(post.getId())) {
+                                                               sone.setKnown(false);
                                                                coreListenerManager.fireNewPostFound(post);
-                                                       } else {
-                                                               sone.setKnown(true);
                                                        }
                                                }
                                                posts.put(post.getId(), post);
@@ -1195,15 +1193,13 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                Set<PostReply> storedReplies = storedSone.getReplies();
                                synchronized (knownReplies) {
                                        for (PostReply reply : sone.getReplies()) {
-                                               reply.setSone(storedSone);
+                                               reply.setSone(storedSone).setKnown(knownReplies.contains(reply.getId()));
                                                if (!storedReplies.contains(reply)) {
                                                        if (reply.getTime() < getSoneFollowingTime(sone)) {
-                                                               reply.setKnown(true);
                                                                knownReplies.add(reply.getId());
                                                        } else if (!knownReplies.contains(reply.getId())) {
+                                                               reply.setKnown(false);
                                                                coreListenerManager.fireNewReplyFound(reply);
-                                                       } else {
-                                                               reply.setKnown(true);
                                                        }
                                                }
                                                replies.put(reply.getId(), reply);
@@ -1297,8 +1293,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        }
 
        /**
-        * Marks the given Sone as known. If the Sone was {@link #isNewPost(String)
-        * new} before, a {@link CoreListener#markSoneKnown(Sone)} event is fired.
+        * Marks the given Sone as known. If the Sone was not {@link Post#isKnown()
+        * known} before, a {@link CoreListener#markSoneKnown(Sone)} event is fired.
         *
         * @param sone
         *            The Sone to mark as known
@@ -1645,8 +1641,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        }
 
        /**
-        * Marks the given post as known, if it is currently a new post (according
-        * to {@link #isNewPost(String)}).
+        * Marks the given post as known, if it is currently not a known post
+        * (according to {@link Post#isKnown()}).
         *
         * @param post
         *            The post to mark as known
@@ -1654,8 +1650,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        public void markPostKnown(Post post) {
                post.setKnown(true);
                synchronized (knownPosts) {
+                       coreListenerManager.fireMarkPostKnown(post);
                        if (knownPosts.add(post.getId())) {
-                               coreListenerManager.fireMarkPostKnown(post);
                                touchConfiguration();
                        }
                }
@@ -1784,8 +1780,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        }
 
        /**
-        * Marks the given reply as known, if it is currently a new reply (according
-        * to {@link #isNewReply(String)}).
+        * Marks the given reply as known, if it is currently not a known reply
+        * (according to {@link Reply#isKnown()}).
         *
         * @param reply
         *            The reply to mark as known
@@ -1793,8 +1789,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        public void markReplyKnown(PostReply reply) {
                reply.setKnown(true);
                synchronized (knownReplies) {
+                       coreListenerManager.fireMarkReplyKnown(reply);
                        if (knownReplies.add(reply.getId())) {
-                               coreListenerManager.fireMarkReplyKnown(reply);
                                touchConfiguration();
                        }
                }