commit 557608db9bee05b8152fc5b68c77bc14c1ba06db
parent 8697a5cb0a0ebd6248d554cfb4200ca40befd8b1
Author: kernelkind <kernelkind@gmail.com>
Date: Thu, 31 Jul 2025 18:55:25 -0400
chrome: method to find whether there are unseen notifications
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs
@@ -477,6 +477,38 @@ impl Chrome {
}
}
+fn unseen_notification(
+ columns: Option<&mut Damus>,
+ ndb: &nostrdb::Ndb,
+ current_pk: notedeck::enostr::Pubkey,
+) -> bool {
+ let Some(columns) = columns else {
+ return false;
+ };
+
+ let Some(tl) = columns
+ .timeline_cache
+ .get_mut(&TimelineKind::Notifications(current_pk))
+ else {
+ return false;
+ };
+
+ let freshness = &mut tl.current_view_mut().freshness;
+ freshness.update(|timestamp_last_viewed| {
+ let filter = notedeck_columns::timeline::kind::notifications_filter(¤t_pk)
+ .since_mut(timestamp_last_viewed);
+ let txn = Transaction::new(ndb).expect("txn");
+
+ let Some(res) = ndb.query(&txn, &[filter], 1).ok() else {
+ return false;
+ };
+
+ !res.is_empty()
+ });
+
+ freshness.has_unseen()
+}
+
impl notedeck::App for Chrome {
fn update(&mut self, ctx: &mut notedeck::AppContext, ui: &mut egui::Ui) -> Option<AppAction> {
if let Some(action) = self.show(ctx, ui) {