From 2463c2c5e852aea6b90294f55ffcb17e9eb822eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 13 Nov 2011 12:31:07 +0100 Subject: [PATCH] Fix added-or-removed detection by making it context-sensitive. --- .../java/net/pterodactylus/sone/freenet/wot/IdentityManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); } } -- 2.7.4