X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=50450c4f00bf22ff7ee24e897efa3d3662a53991;hp=108b05c712b40f0ec033c40dadf6028a7d232f18;hb=c10366d9afaf5db18936fc570d290d5e5550a8d8;hpb=c03a4ced3dd1562f4387edb449680a6fd8b9a746 diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 108b05c..50450c4 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -24,8 +24,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Level; @@ -40,12 +40,12 @@ import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Profile; +import net.pterodactylus.sone.data.Profile.Field; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.data.TemporaryImage; -import net.pterodactylus.sone.data.Profile.Field; import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; import net.pterodactylus.sone.data.Sone.SoneStatus; +import net.pterodactylus.sone.data.TemporaryImage; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; import net.pterodactylus.sone.freenet.wot.Identity; @@ -131,45 +131,45 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis /** All local Sones. */ /* synchronize access on this on itself. */ - private Map localSones = new HashMap(); + private final Map localSones = new HashMap(); /** All remote Sones. */ /* synchronize access on this on itself. */ - private Map remoteSones = new HashMap(); + private final Map remoteSones = new HashMap(); /** All known Sones. */ - private Set knownSones = new HashSet(); + private final Set knownSones = new HashSet(); /** All posts. */ - private Map posts = new HashMap(); + private final Map posts = new HashMap(); /** All known posts. */ - private Set knownPosts = new HashSet(); + private final Set knownPosts = new HashSet(); /** All replies. */ - private Map replies = new HashMap(); + private final Map replies = new HashMap(); /** All known replies. */ - private Set knownReplies = new HashSet(); + private final Set knownReplies = new HashSet(); /** All bookmarked posts. */ /* synchronize access on itself. */ - private Set bookmarkedPosts = new HashSet(); + private final Set bookmarkedPosts = new HashSet(); /** Trusted identities, sorted by own identities. */ - private Map> trustedIdentities = Collections.synchronizedMap(new HashMap>()); + private final Map> trustedIdentities = Collections.synchronizedMap(new HashMap>()); /** All known albums. */ - private Map albums = new HashMap(); + private final Map albums = new HashMap(); /** All known images. */ - private Map images = new HashMap(); + private final Map images = new HashMap(); /** All temporary images. */ - private Map temporaryImages = new HashMap(); + private final Map temporaryImages = new HashMap(); /** Ticker for threads that mark own elements as known. */ - private Ticker localElementTicker = new Ticker(); + private final Ticker localElementTicker = new Ticker(); /** The time the configuration was last touched. */ private volatile long lastConfigurationUpdate; @@ -1293,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 @@ -1456,7 +1456,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis } parentAlbum.addAlbum(album); } else { - topLevelAlbums.add(album); + if (!topLevelAlbums.contains(album)) { + topLevelAlbums.add(album); + } } } @@ -1641,8 +1643,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 @@ -1650,11 +1652,14 @@ 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(); } } + for (PostReply reply : getReplies(post)) { + markReplyKnown(reply); + } } /** @@ -1780,8 +1785,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 @@ -1789,8 +1794,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(); } }