[folks] Refactor Individual.update_alias() to give a single notification path



commit 1f549b38b0b1edd0f352153de8b58711a2b594b3
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Aug 30 16:43:36 2010 +0100

    Refactor Individual.update_alias() to give a single notification path

 folks/individual.vala |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index 27e54e2..7529f76 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -517,12 +517,7 @@ public class Folks.Individual : Object,
               if (a.alias != null && a.alias.strip () != "")
                 {
                   alias = a.alias;
-
-                  /* Only notify if the value has changed */
-                  if (this.alias != alias)
-                    this.alias = alias;
-
-                  return;
+                  break;
                 }
             }
         }
@@ -531,28 +526,31 @@ public class Folks.Individual : Object,
        * the aliases from other personas. Use a non-empty alias which isn't
        * equal to the persona's display ID as our preference. If we can't find
        * one of those, fall back to one which is equal to the display ID. */
-      foreach (Persona p in this._persona_list)
+      if (alias == null)
         {
-          if (p is Alias)
+          foreach (Persona p in this._persona_list)
             {
-              unowned Alias a = (Alias) p;
-
-              if (a.alias == null || a.alias.strip () == "")
-                continue;
-
-              if (alias == null || alias_is_display_id == true)
+              if (p is Alias)
                 {
-                  /* We prefer to not have an alias which is the same as the
-                   * Persona's display-id, since having such an alias implies
-                   * that it's the default. However, we prefer using such an
-                   * alias to using the Persona's UID, which is our ultimate
-                   * fallback (below). */
-                  alias = a.alias;
-
-                  if (a.alias == p.display_id)
-                    alias_is_display_id = true;
-                  else if (alias != null)
-                    break;
+                  unowned Alias a = (Alias) p;
+
+                  if (a.alias == null || a.alias.strip () == "")
+                    continue;
+
+                  if (alias == null || alias_is_display_id == true)
+                    {
+                      /* We prefer to not have an alias which is the same as the
+                       * Persona's display-id, since having such an alias
+                       * implies that it's the default. However, we prefer using
+                       * such an alias to using the Persona's UID, which is our
+                       * ultimate fallback (below). */
+                      alias = a.alias;
+
+                      if (a.alias == p.display_id)
+                        alias_is_display_id = true;
+                      else if (alias != null)
+                        break;
+                    }
                 }
             }
         }



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