[folks] Write alias changes to every Persona if there are no writeable Personas



commit c9afc15599021aa2b4a18ccd1563662c35290a3d
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Aug 25 18:08:35 2010 +0100

    Write alias changes to every Persona if there are no writeable Personas
    
    This is necessary for singleton Individuals which only contain a Tpf.Persona.

 folks/individual.vala |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index 4d9e9c5..5dcfc4a 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -149,11 +149,28 @@ public class Folks.Individual : Object,
             return;
 
           this._alias = value;
+
+          /* First, try to write it to only the writeable Personasâ?¦ */
+          bool alias_changed = false;
           this._persona_list.foreach ((p) =>
             {
               if (p is Alias && ((Persona) p).store.is_writeable == true)
-                ((Alias) p).alias = value;
+                {
+                  ((Alias) p).alias = value;
+                  alias_changed = true;
+                }
             });
+
+          /* â?¦but if there are no writeable Personas, we have to fall back to
+           * writing it to every Persona. */
+          if (alias_changed == false)
+            {
+              this._persona_list.foreach ((p) =>
+                {
+                  if (p is Alias)
+                    ((Alias) p).alias = value;
+                });
+            }
         }
     }
 



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