Some fixups for the badge
This commit is contained in:
@@ -2,7 +2,7 @@ using Adw;
|
||||
using Gtk;
|
||||
|
||||
public class ConversationRow : Adw.ActionRow {
|
||||
private Label? unread_badge;
|
||||
private Label unread_badge;
|
||||
|
||||
public ConversationRow(Conversation conversation) {
|
||||
Object();
|
||||
@@ -11,12 +11,15 @@ public class ConversationRow : Adw.ActionRow {
|
||||
subtitle = conversation.last_message_preview;
|
||||
subtitle_lines = 1;
|
||||
|
||||
// Add unread badge if needed
|
||||
if (conversation.is_unread && conversation.unread_count > 0) {
|
||||
unread_badge = new Label(conversation.unread_count.to_string());
|
||||
unread_badge.add_css_class("badge");
|
||||
unread_badge.add_css_class("accent");
|
||||
add_suffix(unread_badge);
|
||||
unread_badge = new Label(conversation.unread_count.to_string());
|
||||
unread_badge.add_css_class("badge");
|
||||
unread_badge.add_css_class("accent");
|
||||
add_prefix(unread_badge);
|
||||
|
||||
if (conversation.is_unread) {
|
||||
unread_badge.opacity = 1.0;
|
||||
} else {
|
||||
unread_badge.opacity = 0.0;
|
||||
}
|
||||
|
||||
// Add timestamp if available
|
||||
|
||||
@@ -3,11 +3,12 @@ using GLib;
|
||||
public class Conversation : Object {
|
||||
public string id { get; set; default = ""; }
|
||||
public string last_message_preview { get; set; default = ""; }
|
||||
public bool is_unread { get; set; default = false; }
|
||||
public int64 date { get; set; default = 0; }
|
||||
public string[] participants { get; set; default = new string[0]; }
|
||||
public int unread_count { get; set; default = 0; }
|
||||
|
||||
public bool is_unread { get { return unread_count > 0; } }
|
||||
|
||||
public string display_name {
|
||||
owned get {
|
||||
if (_display_name != null && _display_name.length > 0) {
|
||||
@@ -54,11 +55,6 @@ public class Conversation : Object {
|
||||
last_message_preview = last_message_variant.get_string();
|
||||
}
|
||||
|
||||
Variant? is_unread_variant = dict.lookup_value("is_unread", VariantType.BOOLEAN);
|
||||
if (is_unread_variant != null) {
|
||||
is_unread = is_unread_variant.get_boolean();
|
||||
}
|
||||
|
||||
Variant? date_variant = dict.lookup_value("date", VariantType.INT64);
|
||||
if (date_variant != null) {
|
||||
date = date_variant.get_int64();
|
||||
|
||||
Reference in New Issue
Block a user