[gnome-contacts/nielsdg/fix-ignored-individuals: 1/2] utils: Ensure pure key-file individuals are ignored




commit 7831ea3d4b4cd7fa11a9538317c1bd1a5af80043
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Sep 8 07:55:42 2022 +0200

    utils: Ensure pure key-file individuals are ignored
    
    Since linking is done by creating entries in the `relationships.ini`
    file which end up as a Persona, we can have an individual which consists
    of multiple Personas, all from the key-file backend. This is not
    something we accounted for in the `Utils.is_ignorable` function, so this
    commit fixes that.

 src/contacts-utils.vala | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index f261be99..fbbb1f8f 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -66,23 +66,21 @@ namespace Contacts.Utils {
   }
 
   public bool is_ignorable (Individual individual) {
-    var i = individual.personas.iterator();
-
-    // Look for single-persona individuals
-    if (i.next() && !i.has_next ()) {
-      var persona_store = i.get().store;
-
+    foreach (var persona in individual.personas) {
       // Filter out pure key-file persona individuals as these are not very interesting
-      if (persona_store.type_id == "key-file")
-        return true;
+      if (persona.store.type_id == "key-file")
+        continue;
 
       // Filter out uncertain things like link-local xmpp
-      if (persona_store.type_id == "telepathy" &&
-          persona_store.trust_level == PersonaStoreTrust.NONE)
-        return true;
+      if (persona.store.type_id == "telepathy" &&
+          persona.store.trust_level == PersonaStoreTrust.NONE)
+        continue;
+
+      // If we have any other kind of persona, don't ignore
+      return false;
     }
 
-    return false;
+    return true;
   }
 
   /* We claim something is "removable" if at least one persona is removable,


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