aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-08-27 09:48:25 -0400
committerfrosty <gabriel@bwaaa.monster>2026-08-27 09:48:25 -0400
commitb308e9f032f1f6013f8dd0ec563777638d97743e (patch)
treef2b7036b6821c3647d329a9c0c605226a47ab9d4
parentfd6d6a8a2c6cd7b158d92601e4f3a55117a3983e (diff)
feat: add mark all as read option
-rw-r--r--libdino/src/service/chat_interaction.vala18
-rw-r--r--main/data/menu_app.ui6
-rw-r--r--main/src/ui/application.vala6
3 files changed, 30 insertions, 0 deletions
diff --git a/libdino/src/service/chat_interaction.vala b/libdino/src/service/chat_interaction.vala
index 9c8106a0..b3ec1b93 100644
--- a/libdino/src/service/chat_interaction.vala
+++ b/libdino/src/service/chat_interaction.vala
@@ -51,6 +51,24 @@ public class ChatInteraction : StreamInteractionModule, Object {
return (int) query.count();
}
+ public async void mark_all_as_read() {
+ ContentItemStore content_item_store = stream_interactor.get_module(ContentItemStore.IDENTITY);
+ CounterpartInteractionManager counterpart_interaction_manager = stream_interactor.get_module(CounterpartInteractionManager.IDENTITY);
+
+ foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations()) {
+ if (get_num_unread(conversation) == 0) continue;
+
+ ContentItem? latest_item = content_item_store.get_latest(conversation);
+ if (latest_item == null) continue;
+
+ Message? message = content_item_store.get_message_for_content_item(conversation, latest_item);
+ if (message != null) {
+ yield send_and_mark_message_displayed(conversation, message);
+ }
+ counterpart_interaction_manager.mark_displayed_up_to_content_item(conversation, latest_item);
+ }
+ }
+
public bool is_active_focus(Conversation? conversation = null) {
if (conversation != null) {
return focus_in && conversation.equals(this.selected_conversation);
diff --git a/main/data/menu_app.ui b/main/data/menu_app.ui
index bbcddb6d..c056c1aa 100644
--- a/main/data/menu_app.ui
+++ b/main/data/menu_app.ui
@@ -13,6 +13,12 @@
</section>
<section>
<item>
+ <attribute name="action">app.mark_all_as_read</attribute>
+ <attribute name="label" translatable="yes">Mark all as read</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
<attribute name="action">app.preferences</attribute>
<attribute name="label" translatable="yes">Preferences</attribute>
</item>
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index b72a8d0e..ea4f578c 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -153,6 +153,12 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
about_action.activate.connect(show_about_window);
add_action(about_action);
+ SimpleAction mark_all_as_read_action = new SimpleAction("mark_all_as_read", null);
+ mark_all_as_read_action.activate.connect(() => {
+ stream_interactor.get_module(ChatInteraction.IDENTITY).mark_all_as_read.begin();
+ });
+ add_action(mark_all_as_read_action);
+
SimpleAction quit_action = new SimpleAction("quit", null);
quit_action.activate.connect(quit);
add_action(quit_action);