From 4326c7d4d60c273fc608f6e2ed2fae0213566e5c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 22 Jun 2023 09:07:08 +0200 Subject: [PATCH] Button to mark all as read in the inbox --- src/components/inbox_page.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/inbox_page.rs b/src/components/inbox_page.rs index 4c129e8..bf93d4c 100644 --- a/src/components/inbox_page.rs +++ b/src/components/inbox_page.rs @@ -24,7 +24,8 @@ pub enum InboxInput { UpdateType(InboxType), ToggleUnreadState, FetchInbox, - UpdateInbox(Vec) + UpdateInbox(Vec), + MarkAllAsRead, } #[relm4::component(pub)] @@ -53,6 +54,10 @@ impl SimpleComponent for InboxPage { set_label: "Show unread only", connect_clicked => InboxInput::ToggleUnreadState, }, + gtk::Button { + set_label: "Mark all as read", + connect_clicked => InboxInput::MarkAllAsRead, + } }, gtk::ScrolledWindow { #[local_ref] @@ -115,6 +120,14 @@ impl SimpleComponent for InboxPage { self.mentions.guard().push_back(comment); } } + InboxInput::MarkAllAsRead => { + let show_unread_only = self.unread_only.clone(); + std::thread::spawn(move || { + if api::user::mark_all_as_read().is_ok() && show_unread_only { + sender.input(InboxInput::UpdateInbox(vec![])); + } + }); + } } } }