aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2018-12-04 10:21:24 +0100
committerfiaxh <fiaxh@users.noreply.github.com>2018-12-28 13:42:58 +0100
commitd8e0ab406cdad73edf79123e84d0013b96a3963a (patch)
tree4de13499d19113f96b5720a0554f95a3feb707b7 /main/src/ui
parent965f4da75ae5a5b308191bd61890b4277504f5b1 (diff)
downloaddino-d8e0ab406cdad73edf79123e84d0013b96a3963a.tar.gz
dino-d8e0ab406cdad73edf79123e84d0013b96a3963a.zip
display groups w/o name by list of members
For members-only, non-anonymous groups that do not have a name set we now show an automatically generated name that is generated from the list of members (offline, and online). Only the first name (before the first space) is used to keep the generated name short. The term *private room* is coined as a short hand for members only&non-anon group chats. This commit also uses the offline members list instead of the online member list to generate avatar tiles (also only in members-only, non-anon groups.)
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/avatar_image.vala15
-rw-r--r--main/src/ui/conversation_selector/conversation_row.vala5
-rw-r--r--main/src/ui/conversation_titlebar/view.vala6
-rw-r--r--main/src/ui/util/helper.vala17
4 files changed, 41 insertions, 2 deletions
diff --git a/main/src/ui/avatar_image.vala b/main/src/ui/avatar_image.vala
index bf6cb9f4..f6140c26 100644
--- a/main/src/ui/avatar_image.vala
+++ b/main/src/ui/avatar_image.vala
@@ -194,6 +194,7 @@ public class AvatarImage : Misc {
stream_interactor.get_module(AvatarManager.IDENTITY).received_avatar.disconnect(on_received_avatar);
stream_interactor.connection_manager.connection_state_changed.disconnect(on_connection_changed);
stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.disconnect(on_roster_updated);
+ stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.disconnect(on_occupant_updated);
}
}
@@ -205,10 +206,16 @@ public class AvatarImage : Misc {
stream_interactor.get_module(AvatarManager.IDENTITY).received_avatar.connect(on_received_avatar);
stream_interactor.connection_manager.connection_state_changed.connect(on_connection_changed);
stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect(on_roster_updated);
+ stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect(on_occupant_updated);
}
if (muc_manager.is_groupchat(jid_, account) && avatar_manager.get_avatar(account, jid_) == null) {
// Groupchat without avatar
- Gee.List<Jid>? occupants = muc_manager.get_other_occupants(jid_, account);
+ Gee.List<Jid>? occupants;
+ if (muc_manager.is_private_room(account, jid_)) {
+ occupants = muc_manager.get_other_offline_members(jid_, account);
+ } else {
+ occupants = muc_manager.get_other_occupants(jid_, account);
+ }
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()))) {
@@ -292,6 +299,12 @@ public class AvatarImage : Misc {
set_jid(stream_interactor, this.jid, account, true);
}
+ private void on_occupant_updated(Account account, Jid room, Jid occupant) {
+ if (!account.equals(this.account)) return;
+ if (!room.equals_bare(this.jid)) return;
+ set_jid(stream_interactor, this.jid, account, true);
+ }
+
private bool is_self_online() {
return stream_interactor.connection_manager.get_state(account) == ConnectionManager.ConnectionState.CONNECTED;
}
diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala
index 6327e07d..992cf107 100644
--- a/main/src/ui/conversation_selector/conversation_row.vala
+++ b/main/src/ui/conversation_selector/conversation_row.vala
@@ -59,6 +59,11 @@ public class ConversationRow : ListBoxRow {
update_name_label();
}
});
+ stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect((account, room, occupant) => {
+ if (conversation != null && conversation.counterpart.equals_bare(room.bare_jid) && conversation.account.equals(account)) {
+ update_name_label();
+ }
+ });
break;
case Conversation.Type.GROUPCHAT_PM:
break;
diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala
index 7ee47311..7ced9830 100644
--- a/main/src/ui/conversation_titlebar/view.vala
+++ b/main/src/ui/conversation_titlebar/view.vala
@@ -42,6 +42,12 @@ public class ConversationTitlebar : Gtk.HeaderBar {
}
});
+ stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect((account, room, occupant) => {
+ if (conversation != null && conversation.counterpart.equals_bare(room.bare_jid) && conversation.account.equals(account)) {
+ update_title();
+ }
+ });
+
stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => {
if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) {
update_subtitle(subject);
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index 2f2bb84d..da854513 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -60,10 +60,25 @@ public static string get_conversation_display_name(StreamInteractor stream_inter
public static string get_display_name(StreamInteractor stream_interactor, Jid jid, Account account) {
if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat(jid, account)) {
- string room_name = stream_interactor.get_module(MucManager.IDENTITY).get_room_name(account, jid);
+ MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY);
+ string room_name = muc_manager.get_room_name(account, jid);
if (room_name != null && room_name != jid.localpart) {
return room_name;
}
+ if (muc_manager.is_private_room(account, jid)) {
+ Gee.List<Jid>? other_occupants = muc_manager.get_other_offline_members(jid, account);
+ if (other_occupants != null && other_occupants.size > 0) {
+ var builder = new StringBuilder ();
+ foreach(Jid occupant in other_occupants) {
+
+ if (builder.len != 0) {
+ builder.append(", ");
+ }
+ builder.append(get_display_name(stream_interactor, occupant, account).split(" ")[0]);
+ }
+ return builder.str;
+ }
+ }
return jid.bare_jid.to_string();
} else if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) {
return jid.resourcepart;