Button to mark all as read in the inbox

This commit is contained in:
Bnyro 2023-06-22 09:07:08 +02:00
parent 1ebfa7776f
commit 4326c7d4d6
1 changed files with 14 additions and 1 deletions

View File

@ -24,7 +24,8 @@ pub enum InboxInput {
UpdateType(InboxType),
ToggleUnreadState,
FetchInbox,
UpdateInbox(Vec<CommentReplyView>)
UpdateInbox(Vec<CommentReplyView>),
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![]));
}
});
}
}
}
}