From dd47d26cd7d08fa1efb9c4f70a33fc0c1a1223d0 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Fri, 8 Dec 2023 02:02:29 +0100 Subject: Show roster presence status on new chat window should close #139 --- main/src/ui/add_conversation/conference_list.vala | 1 + main/src/ui/add_conversation/list_row.vala | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'main/src/ui/add_conversation') diff --git a/main/src/ui/add_conversation/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala index 0b630ae4..0d840472 100644 --- a/main/src/ui/add_conversation/conference_list.vala +++ b/main/src/ui/add_conversation/conference_list.vala @@ -103,6 +103,7 @@ internal class ConferenceListRow : ListRow { this.account = account; this.bookmark = bookmark; + status_label.visible = false; name_label.label = bookmark.name != null && bookmark.name != "" ? bookmark.name : bookmark.jid.to_string(); if (stream_interactor.get_accounts().size > 1) { via_label.label = "via " + account.bare_jid.to_string(); diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index c5e344d0..8ba9c4cd 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -11,6 +11,7 @@ public class ListRow : Widget { public Grid outer_grid; public AvatarPicture picture; public Label name_label; + public Label status_label; public Label via_label; public Jid? jid; @@ -21,6 +22,7 @@ public class ListRow : Widget { outer_grid = (Grid) builder.get_object("outer_grid"); picture = (AvatarPicture) builder.get_object("picture"); name_label = (Label) builder.get_object("name_label"); + status_label = (Label) builder.get_object("status_label"); via_label = (Label) builder.get_object("via_label"); this.layout_manager = new BinLayout(); @@ -46,6 +48,21 @@ public class ListRow : Widget { } name_label.label = display_name; picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conv); + Gee.List? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(jid, account); + if (full_jids != null){ + for (int i = 0; i < full_jids.size; i++) { + Jid full_jid = full_jids[i]; + string? presence_str = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, account); + switch(presence_str){ + case "online": status_label.label = "" + _("Online") + ""; break; + case "xa": status_label.label = "" + _("Extended Away") + ""; break; + case "away": status_label.label = "" + _("Away") + ""; break; + case "chat": status_label.label = "" + _("Chatting") +""; break; + case "dnd": status_label.label = "" + _("Do not disturb") + ""; break; + } + } + } + else status_label.label = "Offline"; } public override void dispose() { -- cgit v1.2.3-70-g09d2