[folks/648811-dummy-backend-rebase1] individual: Allow Individual.id to be an empty string with no personas



commit 248997873c8a2321fb898142340da3f2c5441baf
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Nov 21 20:08:55 2013 +0000

    individual: Allow Individual.id to be an empty string with no personas
    
    If an Individual has no Personas (as can happen when it’s just been
    constructed), document the ID as being the empty string. This is a
    special case.
    
    Previously, the ID defaulted to being null, which violated its specified
    type.

 folks/individual.vala |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index c8b6277..e1d804d 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -286,8 +286,11 @@ public class Folks.Individual : Object,
    * instead. For example, if storing references to Individuals who are tagged
    * in a photo, it may be safer to store the UID of the Persona whose backend
    * provided the photo (e.g. Facebook).
+   *
+   * As a special case, the ID defaults to an empty string when the individual
+   * has no personas (i.e. if it’s just been constructed).
    */
-  public string id { get; private set; }
+  public string id { get; private set; default = ""; }
 
   /**
    * Emitted when the last of the Individual's { link Persona}s has been
@@ -2632,6 +2635,11 @@ public class Folks.Individual : Object,
           this.id = Checksum.compute_for_string (ChecksumType.SHA1,
               ((!) chosen_persona).uid);
         }
+      else
+        {
+          /* Default if we have no personas. */
+          this.id = "";
+        }
 
       /* Update our aggregated fields and notify the changes */
       this._update_fields ();


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