X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=565aec4679b93e9d98117cefe98833a68595fb7f;hp=e94924c9e2f5aa29f39867d89535f90b837e847a;hb=f187773b693959d19248b31d9b2091c37114b60b;hpb=dd9a400b5a3c06c5c23c0e6a2eb0f770f25ac231 diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e94924c..565aec4 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1168,15 +1168,13 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis List 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 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(); } }