From 81310dff2e712cf7ddbce7c4717cd5a77170c79a Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 7 Mar 2018 17:24:57 +0100 Subject: Handle multiple chat state notifications per bare jid fixes #117 --- main/src/ui/avatar_image.vala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'main/src/ui/avatar_image.vala') diff --git a/main/src/ui/avatar_image.vala b/main/src/ui/avatar_image.vala index 98460a57..baee12c7 100644 --- a/main/src/ui/avatar_image.vala +++ b/main/src/ui/avatar_image.vala @@ -184,7 +184,7 @@ public class AvatarImage : Misc { jid = jid_; if (occupants == null || occupants.size == 0) { if (force_update || current_jids.length != 1 || !current_jids[0].equals(jid_) || gray != (allow_gray && (occupants == null || !is_self_online()))) { - set_jids(new Jid[] {jid_}, false, occupants == null || !is_self_online()); + set_jids_(new Jid[] {jid_}, false, occupants == null || !is_self_online()); } } else if (occupants.size > 4) { bool requires_update = force_update; @@ -195,7 +195,7 @@ public class AvatarImage : Misc { } } if (requires_update) { - set_jids(occupants.slice(0, 3).to_array(), true); + set_jids_(occupants.slice(0, 3).to_array(), true); } } else { // 1 <= occupants.size <= 4 bool requires_update = force_update; @@ -207,18 +207,24 @@ public class AvatarImage : Misc { } } if (requires_update) { - set_jids(occupants.to_array(), false); + set_jids_(occupants.to_array(), false); } } } else { // Single user this.jid = jid_; if (force_update || current_jids.length != 1 || !current_jids[0].equals(jid) || gray != (allow_gray && (!is_counterpart_online(jid) || !is_self_online()))) { - set_jids(new Jid[] { jid }, false, !is_counterpart_online(jid) || !is_self_online()); + set_jids_(new Jid[] { jid }, false, !is_counterpart_online(jid) || !is_self_online()); } } } + public void set_jids(StreamInteractor stream_interactor, Jid[] jids, Account account, bool gray = false) { + this.stream_interactor = stream_interactor; + this.account = account; + set_jids_(jids.length > 3 ? jids[0:3] : jids, jids.length > 3, gray); + } + private void on_show_received(Show show, Jid jid, Account account) { if (!account.equals(this.account)) return; if (jid.equals_bare(this.jid)) { @@ -266,7 +272,7 @@ public class AvatarImage : Misc { return stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(counterpart, account) != null; } - public void set_jids(Jid[] jids, bool with_plus = false, bool gray = false) { + public void set_jids_(Jid[] jids, bool with_plus = false, bool gray = false) { assert(jids.length > 0); assert(jids.length < 5); assert(!with_plus || jids.length == 3); -- cgit v1.2.3-54-g00ecf