X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=dbda28d7f0c3960e5e9800549f27f5855a217ed1;hb=6004444a6a2f604b46d1440cd7f0fbe6502245d5;hp=22ab47b7f93cf68778b3401b58b41ad57b0d1bb5;hpb=7edffb4478bdeae16b009bced9d6769d0cb50a3b;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 22ab47b..dbda28d 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -494,40 +494,15 @@ public class Core implements IdentityListener, UpdateListener { } /** - * Returns whether the Sone with the given ID is a new Sone. After this - * check, the Sone is marked as known, i.e. a second call with the same - * parameters will always yield {@code false}. + * Returns whether the Sone with the given ID is a new Sone. * * @param soneId * The ID of the sone to check for * @return {@code true} if the given Sone is new, false otherwise */ public boolean isNewSone(String soneId) { - return isNewSone(soneId, true); - } - - /** - * Returns whether the Sone with the given ID is a new Sone. The Sone will - * be marked as known if {@code markAsKnown} is {@code true}, otherwise the - * Sone will keep its current “new” state. - * - * @param soneId - * The ID of the sone to check for - * @param markAsKnown - * {@code true} to mark the Sone as known in any case, - * {@code false} to not mark it as known - * @return {@code true} if the given Sone is new, false otherwise - */ - public boolean isNewSone(String soneId, boolean markAsKnown) { synchronized (newSones) { - boolean isNew = !knownSones.contains(soneId) && newSones.contains(soneId); - if (markAsKnown) { - Sone sone = getSone(soneId, false); - if (sone != null) { - markSoneKnown(sone); - } - } - return isNew; + return !knownSones.contains(soneId) && newSones.contains(soneId); } } @@ -589,8 +564,7 @@ public class Core implements IdentityListener, UpdateListener { } /** - * Returns whether the given post ID is new. After this method returns it is - * marked a known post ID. + * Returns whether the given post ID is new. * * @param postId * The post ID @@ -598,32 +572,8 @@ public class Core implements IdentityListener, UpdateListener { * otherwise */ public boolean isNewPost(String postId) { - return isNewPost(postId, true); - } - - /** - * Returns whether the given post ID is new. If {@code markAsKnown} is - * {@code true} then after this method returns the post ID is marked a known - * post ID. - * - * @param postId - * The post ID - * @param markAsKnown - * {@code true} to mark the post ID as known, {@code false} to - * not to mark it as known - * @return {@code true} if the post is considered to be new, {@code false} - * otherwise - */ - public boolean isNewPost(String postId, boolean markAsKnown) { synchronized (newPosts) { - boolean isNew = !knownPosts.contains(postId) && newPosts.contains(postId); - if (markAsKnown) { - Post post = getPost(postId, false); - if (post != null) { - markPostKnown(post); - } - } - return isNew; + return !knownPosts.contains(postId) && newPosts.contains(postId); } } @@ -692,30 +642,8 @@ public class Core implements IdentityListener, UpdateListener { * otherwise */ public boolean isNewReply(String replyId) { - return isNewReply(replyId, true); - } - - /** - * Returns whether the reply with the given ID is new. - * - * @param replyId - * The ID of the reply to check - * @param markAsKnown - * {@code true} to mark the reply as known, {@code false} to not - * to mark it as known - * @return {@code true} if the reply is considered to be new, {@code false} - * otherwise - */ - public boolean isNewReply(String replyId, boolean markAsKnown) { synchronized (newReplies) { - boolean isNew = !knownReplies.contains(replyId) && newReplies.contains(replyId); - if (markAsKnown) { - Reply reply = getReply(replyId, false); - if (reply != null) { - markReplyKnown(reply); - } - } - return isNew; + return !knownReplies.contains(replyId) && newReplies.contains(replyId); } } @@ -1047,10 +975,11 @@ public class Core implements IdentityListener, UpdateListener { } } } + List storedPosts = storedSone.getPosts(); synchronized (newPosts) { for (Post post : sone.getPosts()) { - post.setSone(getSone(post.getSone().getId())); - if (!storedSone.getPosts().contains(post) && !knownPosts.contains(post.getId())) { + post.setSone(storedSone); + if (!storedPosts.contains(post) && !knownPosts.contains(post.getId())) { newPosts.add(post.getId()); coreListenerManager.fireNewPostFound(post); } @@ -1067,10 +996,11 @@ public class Core implements IdentityListener, UpdateListener { } } } + Set storedReplies = sone.getReplies(); synchronized (newReplies) { for (Reply reply : sone.getReplies()) { - reply.setSone(getSone(reply.getSone().getId())); - if (!storedSone.getReplies().contains(reply) && !knownReplies.contains(reply.getId())) { + reply.setSone(storedSone); + if (!storedReplies.contains(reply) && !knownReplies.contains(reply.getId())) { newReplies.add(reply.getId()); coreListenerManager.fireNewReplyFound(reply); } @@ -1152,7 +1082,7 @@ public class Core implements IdentityListener, UpdateListener { public void markSoneKnown(Sone sone) { synchronized (newSones) { if (newSones.remove(sone.getId())) { - knownPosts.add(sone.getId()); + knownSones.add(sone.getId()); coreListenerManager.fireMarkSoneKnown(sone); saveConfiguration(); }