summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-30 16:43:36 +0100
committerTravis Reitter <travis.reitter@collabora.co.uk>2010-08-30 13:54:25 -0700
commit1f549b38b0b1edd0f352153de8b58711a2b594b3 (patch)
treebcfc8ce4897672e268ea4b49d574efa7dc863f72
parent9184070a8450d1a1707245c144d3341f241c6686 (diff)
Refactor Individual.update_alias() to give a single notification path
-rw-r--r--folks/individual.vala48
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;
+ }
}
}
}