PersonaDetail.IS_FAVOURITE))
{
bool is_fav = v.get_boolean ();
- yield this._set_contact_is_favourite (contact, is_fav);
+ this._set_contact_is_favourite (contact, is_fav);
}
}
_("The contact cannot be marked as favourite."));
}
- yield this._set_contact_is_favourite (persona.contact, is_favourite);
- yield this._commit_modified_property (persona, "is-favourite");
-
+ this._set_contact_is_favourite (persona.contact, is_favourite);
/* If this is a Google Contacts address book, change the user's membership
* of the “Starred in Android” group accordingly. See: bgo#661490. */
- if (this._is_google_contacts_address_book ())
- {
- try
- {
- yield persona.change_group (this.android_favourite_group_name,
- is_favourite);
- }
- catch (GLib.Error e1)
- {
- /* We know this will always be a PropertyError. */
- assert (e1 is PropertyError);
- throw (PropertyError) e1;
- }
- }
+ this._set_contact_groups (persona.contact, persona.groups, is_favourite);
+ yield this._commit_modified_property (persona, "is-favourite");
}
- private async void _set_contact_is_favourite (E.Contact contact,
- bool is_favourite)
+ private void _set_contact_is_favourite (E.Contact contact, bool is_favourite)
{
this._remove_attribute (contact, "X-FOLKS-FAVOURITE");
_("Groups are not writeable on this contact."));
}
- yield this._set_contact_groups (persona.contact, groups);
+ this._set_contact_groups (persona.contact, groups, persona.is_favourite);
yield this._commit_modified_property (persona, "groups");
-
- /* If this is a Google Contacts address book and the user's changing
- * membership of the “Starred in Android” group, change our favourite
- * status accordingly. See: bgo#661490. */
- if (this._is_google_contacts_address_book ())
- {
- yield persona.change_is_favourite (
- this.android_favourite_group_name in groups);
- }
}
- private async void _set_contact_groups (E.Contact contact, Set<string> groups)
+ private void _set_contact_groups (E.Contact contact, Set<string> groups,
+ bool is_favourite)
{
var categories = new GLib.List<string> ();
{
continue;
}
+ else if (this._is_google_contacts_address_book () &&
+ group == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
categories.prepend (group);
}
+ /* If this is a Google address book, we must transparently add/remove the
+ * “Starred in Android” group to/from the group list, depending on our
+ * favourite status. */
+ if (is_favourite && this._is_google_contacts_address_book ())
+ {
+ categories.prepend (Edsf.PersonaStore.android_favourite_group_name);
+ }
+
contact.set (ContactField.CATEGORY_LIST, categories);
}
foreach (var category_name in category_names)
{
+ /* Skip the “Starred in Android” group for Google personas; we handle
+ * it later. */
+ if (((Edsf.PersonaStore) store)._is_google_contacts_address_book () &&
+ category_name == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
+
new_categories.add (category_name);
/* Is this a new category? */
foreach (var category_name in this._groups)
{
+ /* Skip the “Starred in Android” group for Google personas; we handle
+ * it later. */
+ if (((Edsf.PersonaStore) store)._is_google_contacts_address_book () &&
+ category_name == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
+
if (!new_categories.contains (category_name))
{
removed_categories.add (category_name);
}
}
+ /* Check whether our favourite status needs updating. */
var old_is_favourite = this._is_favourite;
- /* Make the changes to this._groups and emit signals. */
- foreach (var category_name in removed_categories)
+ if (store._is_google_contacts_address_book ())
{
- /* We link the “Starred in Android” group to Google Contacts address
- * books. See: bgo#661490. */
- if (store._is_google_contacts_address_book () &&
- category_name == Edsf.PersonaStore.android_favourite_group_name)
- {
- this._is_favourite = false;
- }
+ this._is_favourite = false;
- this.group_changed (category_name, false);
- this._groups.remove (category_name);
- }
-
- foreach (var category_name in added_categories)
- {
- if (store._is_google_contacts_address_book () &&
- category_name == Edsf.PersonaStore.android_favourite_group_name)
+ foreach (var category_name in category_names)
{
- this._is_favourite = true;
+ /* We link the “Starred in Android” group to Google Contacts
+ * address books. See: bgo#661490. */
+ if (category_name ==
+ Edsf.PersonaStore.android_favourite_group_name)
+ {
+ this._is_favourite = true;
+ }
}
-
- this._groups.add (category_name);
- this.group_changed (category_name, true);
}
/* Notify if anything's changed. */
}
}
- var store = (Edsf.PersonaStore) this.store;
-
- if (store._is_google_contacts_address_book ())
- {
- is_fav = is_fav ||
- (Edsf.PersonaStore.android_favourite_group_name in this._groups);
- }
-
if (is_fav != this._is_favourite)
{
this._is_favourite = is_fav;
-
- var groups_changed = false;
-
- if (store._is_google_contacts_address_book () &&
- !(Edsf.PersonaStore.android_favourite_group_name in this._groups))
- {
- this._groups.add (Edsf.PersonaStore.android_favourite_group_name);
- this.group_changed (
- Edsf.PersonaStore.android_favourite_group_name, true);
- groups_changed = true;
- }
-
- this.freeze_notify ();
-
- if (groups_changed == true)
- {
- this.notify_property ("groups");
- }
-
this.notify_property ("is-favourite");
-
- this.thaw_notify ();
}
}