[folks] core: Fix individuals_changed_detailed mappings for unlinked individuals



commit 7b74199aeed817fb4b08ee45e427c161fa7d9088
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Sep 6 22:20:12 2011 +0100

    core: Fix individuals_changed_detailed mappings for unlinked individuals
    
    It turns out that we can do a post-processing phase on the mappings to be
    emitted by IndividualAggregator.individuals_changed_detailed and ensure that
    individuals who've been unlinked are represented by a mapping from themselves
    to the set of individuals replacing them, rather than a mapping from
    themselves to null, and null to the set of individuals replacing them.
    
    This probably isn't the most efficient way to fix the problem, but it works
    and I can just about understand it.
    
    Helps: bgo#656689, bgo#657282

 folks/individual-aggregator.vala |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index cb8a316..46007db 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -994,7 +994,6 @@ public class Folks.IndividualAggregator : Object
           if (ind != null)
             {
               removed_individuals.add (ind);
-              individuals_changes.set (ind, null);
             }
 
         }
@@ -1030,7 +1029,6 @@ public class Folks.IndividualAggregator : Object
             user = null;
 
           this._disconnect_from_individual (individual);
-          individual.personas = null;
 
           /* Remove the Individual's links from the link map */
           this._remove_individual_from_link_map (individual);
@@ -1057,6 +1055,31 @@ public class Folks.IndividualAggregator : Object
 
       this._add_personas (relinked_personas, ref user, ref individuals_changes);
 
+      /* Work out which final individuals have replaced the removed_individuals
+       * and update individuals_changes accordingly. */
+      foreach (var individual in removed_individuals)
+        {
+          var added_mapping = false;
+
+          foreach (var persona in individual.personas)
+            {
+              if (!(persona in removed) || (persona in added))
+                {
+                  individuals_changes.remove (null, persona.individual);
+                  individuals_changes.set (individual, persona.individual);
+                  added_mapping = true;
+                }
+            }
+
+          /* Has the individual been removed entirely? */
+          if (added_mapping == false)
+            {
+              individuals_changes.set (individual, null);
+            }
+
+          individual.personas = null;
+        }
+
       /* Notify of changes to this.user */
       this.user = user;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]