aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_selector/conversation_selector_row.vala
diff options
context:
space:
mode:
authorcodedust <codedust@users.noreply.github.com>2020-03-02 21:10:36 +0100
committerfiaxh <git@lightrise.org>2020-07-06 21:52:33 +0200
commit86420fdef11b2833fbc42549c8c5817031876d66 (patch)
treefb51349e7468d64f394901a4d177398865aae580 /main/src/ui/conversation_selector/conversation_selector_row.vala
parent23c021685364de19e64248d0411a7ed2f216700e (diff)
downloaddino-86420fdef11b2833fbc42549c8c5817031876d66.tar.gz
dino-86420fdef11b2833fbc42549c8c5817031876d66.zip
Show bubble containing the number of unread messages in the conversation list (#764)
Co-authored-by: codedust <codedust@users.noreply.github.com> Co-authored-by: fiaxh <git@lightrise.org>
Diffstat (limited to 'main/src/ui/conversation_selector/conversation_selector_row.vala')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala20
1 files changed, 15 insertions, 5 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index a5148a8f..7c25ee8d 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -17,9 +17,11 @@ public class ConversationSelectorRow : ListBoxRow {
[GtkChild] protected Label time_label;
[GtkChild] protected Label nick_label;
[GtkChild] protected Label message_label;
+ [GtkChild] protected Label unread_count_label;
[GtkChild] protected Button x_button;
[GtkChild] protected Revealer time_revealer;
[GtkChild] protected Revealer xbutton_revealer;
+ [GtkChild] protected Revealer unread_count_revealer;
[GtkChild] public Revealer main_revealer;
public Conversation conversation { get; private set; }
@@ -27,7 +29,7 @@ public class ConversationSelectorRow : ListBoxRow {
protected const int AVATAR_SIZE = 40;
protected ContentItem? last_content_item;
- protected bool read = true;
+ protected int num_unread = 0;
protected StreamInteractor stream_interactor;
@@ -202,21 +204,27 @@ public class ConversationSelectorRow : ListBoxRow {
}
protected void update_read() {
- bool current_read_status = !stream_interactor.get_module(ChatInteraction.IDENTITY).has_unread(conversation);
- if (read == current_read_status) return;
- read = current_read_status;
+ int current_num_unread = stream_interactor.get_module(ChatInteraction.IDENTITY).get_num_unread(conversation);
+ if (num_unread == current_num_unread) return;
+ num_unread = current_num_unread;
+
+ if (num_unread == 0) {
+ unread_count_label.visible = false;
- if (read) {
name_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
time_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
nick_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
message_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
} else {
+ unread_count_label.label = num_unread.to_string();
+ unread_count_label.visible = true;
+
name_label.attributes.insert(attr_weight_new(Weight.BOLD));
time_label.attributes.insert(attr_weight_new(Weight.BOLD));
nick_label.attributes.insert(attr_weight_new(Weight.BOLD));
message_label.attributes.insert(attr_weight_new(Weight.BOLD));
}
+
name_label.label = name_label.label; // TODO initializes redrawing, which would otherwise not happen. nicer?
time_label.label = time_label.label;
nick_label.label = nick_label.label;
@@ -227,9 +235,11 @@ public class ConversationSelectorRow : ListBoxRow {
StateFlags curr_flags = get_state_flags();
if ((curr_flags & StateFlags.PRELIGHT) != 0) {
time_revealer.set_reveal_child(false);
+ unread_count_revealer.set_reveal_child(false);
xbutton_revealer.set_reveal_child(true);
} else {
time_revealer.set_reveal_child(true);
+ unread_count_revealer.set_reveal_child(true);
xbutton_revealer.set_reveal_child(false);
}
}