[gnome-contacts] Make master-at-join on the contact, not on the persona



commit 2370fb850fc62621a19475aeb178f2d008456936
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Sep 9 15:18:00 2011 +0200

    Make master-at-join on the contact, not on the persona
    
    Turns out we the old individual doesn't have its personas left at
    replace time, so we store the master-at-join bit on the contact.

 src/contacts-linking.vala |    7 +++----
 src/contacts-store.vala   |    9 +++------
 2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index 00a5120..7acfc08 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -406,8 +406,7 @@ namespace Contacts {
   public async void link_contacts (Contact main, Contact other) {
     // This should not be used as being replaced with the new individual
     // instead we should always pick this contact to keep around
-    var contact_persona = main.individual.personas.to_array()[0];
-    contact_persona.set_data ("contacts-master-at-join", true);
+    main.set_data ("contacts-master-at-join", true);
 
     var main_linkables = get_linkable_attributes_for_individual (main.individual);
     var other_linkables = get_linkable_attributes_for_individual (other.individual);
@@ -449,7 +448,7 @@ namespace Contacts {
 	linkables.add_all (other_linkables);
 	yield (write_persona as NameDetails).change_full_name (main.display_name);
       } catch (GLib.Error e) {
-	contact_persona.set_data ("contacts-master-at-join", false);
+	main.set_data ("contacts-master-at-join", false);
 	warning ("Unable to create new persona when linking: %s\n", e.message);
 	return;
       }
@@ -457,7 +456,7 @@ namespace Contacts {
 
     yield persona_apply_attributes (write_persona, linkables, null);
 
-    contact_persona.set_data ("contacts-master-at-join", false);
+    main.set_data ("contacts-master-at-join", false);
   }
 
   public async void unlink_persona (Contact contact, Persona persona_to_unlink) {
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index 7d232a1..b44c7c9 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -50,12 +50,9 @@ public class Contacts.Store : GLib.Object {
     return true;
   }
 
-  private bool individual_should_replace_at_join (Individual new_individual) {
-    foreach (var p in new_individual.personas) {
-      if (p.get_data<bool> ("contacts-master-at-join"))
-	return true;
-    }
-    return false;
+  private bool individual_should_replace_at_join (Individual old_individual) {
+    var c = Contact.from_individual (old_individual);
+    return c.get_data<bool> ("contacts-master-at-join");
   }
 
   public Store () {



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