aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/entity/settings.vala
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-08-17 17:58:03 -0400
committerfrosty <gabriel@bwaaa.monster>2026-08-17 17:58:03 -0400
commitb35e793a5dd52cc345747f531653270765454934 (patch)
tree843022cb45dd33c94c750bbee27b89f3d474d558 /libdino/src/entity/settings.vala
parentf9e3b8ba7da220746151179ed10a90c2ac215ffc (diff)
Begin work on colourable accounts in message list
Diffstat (limited to 'libdino/src/entity/settings.vala')
-rw-r--r--libdino/src/entity/settings.vala23
1 files changed, 23 insertions, 0 deletions
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala
index c71a8e57..1b533667 100644
--- a/libdino/src/entity/settings.vala
+++ b/libdino/src/entity/settings.vala
@@ -2,6 +2,8 @@ namespace Dino.Entities {
public class Settings : Object {
+ public signal void account_color_changed(Account account, string color);
+
private Database db;
public Settings.from_db(Database db) {
@@ -110,6 +112,27 @@ public class Settings : Object {
}
+
+ public string get_account_color(Account account) {
+ string? setting = db.account_settings.get_value(account.id, "conversation-list-color");
+ if (setting != null && setting.length > 0) {
+ return setting;
+ }
+
+ uint8[] rgb = Xmpp.Xep.ConsistentColor.string_to_rgb(account.bare_jid.to_string());
+ return "#%02x%02x%02x".printf(rgb[0], rgb[1], rgb[2]).up();
+ }
+
+ public void set_account_color(Account account, string color) {
+ if (color == get_account_color(account)) return;
+
+ db.account_settings.upsert()
+ .value(db.account_settings.key, "conversation-list-color", true)
+ .value(db.account_settings.account_id, account.id, true)
+ .value(db.account_settings.value, color)
+ .perform();
+ account_color_changed(account, color);
+ }
}
}