Commit 0010985f authored by Philip Withnall's avatar Philip Withnall
Browse files

telepathy: Handle contact removals from groups

Closes: https://bugzilla.gnome.org/show_bug.cgi?id=669984
parent f8e59f0d
...@@ -14,6 +14,7 @@ Bugs fixed: ...@@ -14,6 +14,7 @@ Bugs fixed:
* Bug 670348 — Handle Telepathy CMs crashing/being invalidated * Bug 670348 — Handle Telepathy CMs crashing/being invalidated
* Bug 671900 — Folks should not suggest linking contacts from telepathy-salut * Bug 671900 — Folks should not suggest linking contacts from telepathy-salut
* Bug 670872 — Should be less sensitive to accentuated chars * Bug 670872 — Should be less sensitive to accentuated chars
* Bug 669984 — Does not notify when contacts are added to groups
Overview of changes from libfolks 0.6.6 to libfolks 0.6.7 Overview of changes from libfolks 0.6.6 to libfolks 0.6.7
============================================================= =============================================================
......
...@@ -1733,25 +1733,61 @@ public class Tpf.PersonaStore : Folks.PersonaStore ...@@ -1733,25 +1733,61 @@ public class Tpf.PersonaStore : Folks.PersonaStore
var channel_handle = (Handle) adds.index (i); var channel_handle = (Handle) adds.index (i);
var contact_handle = channel.group_get_handle_owner ( var contact_handle = channel.group_get_handle_owner (
channel_handle); channel_handle);
var persona = this._handle_persona_map[contact_handle];
if (persona == null) HashSet<uint>? contact_handles =
this._channel_group_incoming_adds[channel];
if (contact_handles == null)
{ {
HashSet<uint>? contact_handles = contact_handles = new HashSet<uint> ();
this._channel_group_incoming_adds[channel]; this._channel_group_incoming_adds[channel] =
if (contact_handles == null) contact_handles;
{
contact_handles = new HashSet<uint> ();
this._channel_group_incoming_adds[channel] =
contact_handles;
}
contact_handles.add (contact_handle);
} }
contact_handles.add (contact_handle);
} }
} }
this._channel_groups_add_new_personas (); this._channel_groups_add_new_personas ();
} }
private void _channel_group_handle_incoming_removes (Channel channel,
Array<uint> removes)
{
var removes_length = removes != null ? removes.length : 0;
if (removes_length >= 1)
{
var members_removed = new GLib.List<Persona> ();
HashSet<Persona> members = this._channel_group_personas_map[channel];
if (members == null)
members = new HashSet<Persona> ();
for (var i = 0; i < removes.length; i++)
{
var channel_handle = (Handle) removes.index (i);
var contact_handle = channel.group_get_handle_owner (
channel_handle);
var persona = this._handle_persona_map[contact_handle];
if (persona != null)
{
members.remove (persona);
members_removed.prepend (persona);
}
}
this._channel_group_personas_map[channel] = members;
var name = channel.get_identifier ();
if (this._group_is_display_group (name) &&
members_removed.length () > 0)
{
members_removed.reverse ();
this.group_members_changed (name, null, members_removed);
}
}
}
private void _set_up_new_group_channel (Channel channel) private void _set_up_new_group_channel (Channel channel)
{ {
/* hold a ref to the channel here until it's ready, so it doesn't /* hold a ref to the channel here until it's ready, so it doesn't
...@@ -1817,6 +1853,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore ...@@ -1817,6 +1853,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore
if (added != null) if (added != null)
this._channel_group_pend_incoming_adds.begin (channel, added, false); this._channel_group_pend_incoming_adds.begin (channel, added, false);
if (removed != null)
{
this._channel_group_handle_incoming_removes (channel, removed);
}
/* FIXME: continue for the other arrays */ /* FIXME: continue for the other arrays */
} }
......
...@@ -425,14 +425,12 @@ public class Tpf.Persona : Folks.Persona, ...@@ -425,14 +425,12 @@ public class Tpf.Persona : Folks.Persona,
if (is_member) if (is_member)
{ {
if (!this._groups.contains (group)) changed = this._groups.add (group);
{
this._groups.add (group);
changed = true;
}
} }
else else
changed = this._groups.remove (group); {
changed = this._groups.remove (group);
}
if (changed == true) if (changed == true)
this.group_changed (group, is_member); this.group_changed (group, is_member);
......
...@@ -1205,14 +1205,8 @@ public class Folks.Individual : Object, ...@@ -1205,14 +1205,8 @@ public class Folks.Individual : Object,
foreach (var group in new_groups) foreach (var group in new_groups)
{ {
if (!this._groups.contains (group)) if (this._groups.add (group))
{ {
this._groups.add (group);
foreach (var g in this._groups)
{
debug (" %s", g);
}
this.group_changed (group, true); this.group_changed (group, true);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment