From: David ‘Bombe’ Roden Date: Sun, 13 Nov 2011 11:31:07 +0000 (+0100) Subject: Fix added-or-removed detection by making it context-sensitive. X-Git-Tag: 0.7.3^2~9^2~3 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2463c2c5e852aea6b90294f55ffcb17e9eb822eb;p=Sone.git Fix added-or-removed detection by making it context-sensitive. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java index 3c97e55..f9af361 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java @@ -295,14 +295,16 @@ public class IdentityManager extends AbstractService { /* find removed own identities: */ for (OwnIdentity oldOwnIdentity : currentOwnIdentities.values()) { - if (!newOwnIdentities.containsKey(oldOwnIdentity.getId())) { + OwnIdentity newOwnIdentity = newOwnIdentities.get(oldOwnIdentity.getId()); + if ((newOwnIdentity == null) || ((context != null) && oldOwnIdentity.hasContext(context) && !newOwnIdentity.hasContext(context))) { identityListenerManager.fireOwnIdentityRemoved(oldOwnIdentity); } } /* find added own identities. */ for (OwnIdentity currentOwnIdentity : newOwnIdentities.values()) { - if (!currentOwnIdentities.containsKey(currentOwnIdentity.getId())) { + OwnIdentity oldOwnIdentity = currentOwnIdentities.get(currentOwnIdentity.getId()); + if (((oldOwnIdentity == null) && ((context == null) || currentOwnIdentity.hasContext(context))) || ((oldOwnIdentity != null) && (context != null) && (!oldOwnIdentity.hasContext(context) && currentOwnIdentity.hasContext(context)))) { identityListenerManager.fireOwnIdentityAdded(currentOwnIdentity); } }