Add Sones as new when they are first added.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 8 Nov 2010 19:42:20 +0000 (20:42 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Nov 2010 19:50:11 +0000 (20:50 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java

index af1523a..132e4a6 100644 (file)
@@ -106,6 +106,9 @@ public class Core implements IdentityListener {
        /* synchronize access on this on itself. */
        private Map<String, Sone> remoteSones = new HashMap<String, Sone>();
 
+       /** All new Sones. */
+       private Set<Sone> newSones = new HashSet<Sone>();
+
        /** All posts. */
        private Map<String, Post> posts = new HashMap<String, Post>();
 
@@ -508,9 +511,15 @@ public class Core implements IdentityListener {
                        return null;
                }
                synchronized (remoteSones) {
+                       boolean newSone = !isRemoteSone(identity.getId());
                        final Sone sone = getRemoteSone(identity.getId()).setIdentity(identity);
                        sone.setRequestUri(getSoneUri(identity.getRequestUri()));
                        sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0));
+                       if (newSone) {
+                               synchronized (newSones) {
+                                       newSones.add(sone);
+                               }
+                       }
                        remoteSones.put(identity.getId(), sone);
                        soneDownloader.addSone(sone);
                        setSoneStatus(sone, SoneStatus.unknown);