From: David ‘Bombe’ Roden Date: Sat, 28 Jan 2012 22:50:14 +0000 (+0100) Subject: Initialize known-state of posts and replies correctly. X-Git-Tag: 0.8^2~28 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c03a4ced3dd1562f4387edb449680a6fd8b9a746;p=Sone.git Initialize known-state of posts and replies correctly. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e94924c..108b05c 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);