From 71be2abb6a007fd9b4ed3164d70f5cb95d49ce69 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 29 Apr 2020 21:31:23 +0200 Subject: Store last read content item for conversations fixes #495 --- libdino/src/entity/conversation.vala | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libdino/src/entity/conversation.vala') diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index 47ebd5d8..800a28a2 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -34,6 +34,7 @@ public class Conversation : Object { } public Encryption encryption { get; set; default = Encryption.NONE; } public Message? read_up_to { get; set; } + public int read_up_to_item { get; set; default=-1; } public enum NotifySetting { DEFAULT, ON, OFF, HIGHLIGHT } public NotifySetting notify_setting { get; set; default = NotifySetting.DEFAULT; } @@ -67,6 +68,7 @@ public class Conversation : Object { encryption = (Encryption) row[db.conversation.encryption]; int? read_up_to = row[db.conversation.read_up_to]; if (read_up_to != null) this.read_up_to = db.get_message_by_id(read_up_to); + read_up_to_item = row[db.conversation.read_up_to_item]; notify_setting = (NotifySetting) row[db.conversation.notification]; send_typing = (Setting) row[db.conversation.send_typing]; send_marker = (Setting) row[db.conversation.send_marker]; @@ -88,6 +90,9 @@ public class Conversation : Object { if (read_up_to != null) { insert.value(db.conversation.read_up_to, read_up_to.id); } + if (read_up_to_item != -1) { + insert.value(db.conversation.read_up_to_item, read_up_to_item); + } if (nickname != null) { insert.value(db.conversation.resource, nickname); } @@ -161,6 +166,13 @@ public class Conversation : Object { update.set_null(db.conversation.read_up_to); } break; + case "read-up-to-item": + if (read_up_to_item != -1) { + update.set(db.conversation.read_up_to_item, read_up_to_item); + } else { + update.set_null(db.conversation.read_up_to_item); + } + break; case "nickname": update.set(db.conversation.resource, nickname); break; case "active": -- cgit v1.2.3-54-g00ecf