diff --git a/crates/notedeck/src/filter.rs b/crates/notedeck/src/filter.rs index dcdb06babce2..0caca4567940 100644 --- a/crates/notedeck/src/filter.rs +++ b/crates/notedeck/src/filter.rs @@ -234,7 +234,7 @@ impl HybridFilter { HybridFilter::Split(SplitFilter { local, remote }) } - pub fn local(&self) -> NdbQueryPackages { + pub fn local(&self) -> NdbQueryPackages<'_> { match self { Self::Split(split) => NdbQueryPackages { packages: split.local.iter().map(NdbQueryPackage::borrow).collect(), @@ -305,7 +305,7 @@ pub struct NdbQueryPackage { } impl NdbQueryPackage { - pub fn borrow(&self) -> NdbQueryPackageUnowned { + pub fn borrow(&self) -> NdbQueryPackageUnowned<'_> { NdbQueryPackageUnowned { filters: &self.filters, kind: Some(self.kind.clone()), diff --git a/crates/notedeck/src/media/images.rs b/crates/notedeck/src/media/images.rs index 889bc6640c83..4358519aae0c 100644 --- a/crates/notedeck/src/media/images.rs +++ b/crates/notedeck/src/media/images.rs @@ -305,7 +305,7 @@ fn generate_gif( ); if tex_input.send(texture_frame).is_err() { - tracing::debug!("AnimationTextureFrame mpsc stopped abruptly"); + //tracing::debug!("AnimationTextureFrame mpsc stopped abruptly"); break; } } diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs index 7dad29bdd1e5..a7b644c11b6f 100644 --- a/crates/notedeck_columns/src/ui/timeline.rs +++ b/crates/notedeck_columns/src/ui/timeline.rs @@ -1,11 +1,11 @@ use egui::containers::scroll_area::ScrollBarVisibility; -use egui::{vec2, Color32, Direction, Layout, Margin, Pos2, ScrollArea, Sense, Stroke}; +use egui::{Color32, Direction, Layout, Margin, Pos2, ScrollArea, Sense, Stroke, vec2}; use egui_tabs::TabColor; use enostr::Pubkey; use nostrdb::{Note, ProfileRecord, Transaction}; use notedeck::name::get_display_name; use notedeck::ui::is_narrow; -use notedeck::{tr_plural, JobsCache, Muted, NotedeckTextStyle}; +use notedeck::{JobsCache, Muted, NotedeckTextStyle, tr_plural}; use notedeck_ui::app_images::{like_image, repost_image}; use notedeck_ui::{ProfilePic, ProfilePreview}; use std::f32::consts::PI; @@ -16,11 +16,11 @@ use crate::timeline::{ TimelineTab, ViewFilter, }; use notedeck::{ - note::root_note_id_from_selected_id, tr, Localization, NoteAction, NoteContext, ScrollInfo, + Localization, NoteAction, NoteContext, ScrollInfo, note::root_note_id_from_selected_id, tr, }; use notedeck_ui::{ - anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE}, NoteOptions, NoteView, + anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE}, }; pub struct TimelineView<'a, 'd> { @@ -88,7 +88,7 @@ fn timeline_ui( ui: &mut egui::Ui, timeline_id: &TimelineKind, timeline_cache: &mut TimelineCache, - note_options: NoteOptions, + mut note_options: NoteOptions, note_context: &mut NoteContext, jobs: &mut JobsCache, col: usize, @@ -181,6 +181,10 @@ fn timeline_ui( let txn = Transaction::new(note_context.ndb).expect("failed to create txn"); + if matches!(timeline_id, TimelineKind::Notifications(_)) { + note_options.set(NoteOptions::Notification, true) + } + TimelineTabView::new( timeline.current_view(), note_options, @@ -188,7 +192,6 @@ fn timeline_ui( note_context, jobs, ) - .notifications(matches!(timeline_id, TimelineKind::Notifications(_))) .show(ui) }); @@ -376,7 +379,6 @@ fn shrink_range_to_width(range: egui::Rangef, width: f32) -> egui::Rangef { } pub struct TimelineTabView<'a, 'd> { - notifications: bool, tab: &'a TimelineTab, note_options: NoteOptions, txn: &'a Transaction, @@ -394,7 +396,6 @@ impl<'a, 'd> TimelineTabView<'a, 'd> { jobs: &'a mut JobsCache, ) -> Self { Self { - notifications: false, tab, note_options, txn, @@ -403,11 +404,6 @@ impl<'a, 'd> TimelineTabView<'a, 'd> { } } - pub fn notifications(mut self, notifications: bool) -> Self { - self.notifications = notifications; - self - } - pub fn show(&mut self, ui: &mut egui::Ui) -> Option { let mut action: Option = None; let len = self.tab.units.len(); @@ -509,7 +505,6 @@ impl<'a, 'd> TimelineTabView<'a, 'd> { self.txn, &underlying_note, repost_unit, - self.notifications, ), }, } @@ -745,7 +740,6 @@ fn render_composite_entry( underlying_note: &nostrdb::Note<'_>, profiles_to_show: Vec, composite_type: CompositeType, - notification: bool, ) -> RenderEntryResponse { let first_name = get_display_name(profiles_to_show.iter().find_map(|opt| opt.record.as_ref())) .name() @@ -782,7 +776,6 @@ fn render_composite_entry( profiles_to_show, &composite_type, note_context.img_cache, - notification, ) }, ) @@ -797,7 +790,6 @@ fn render_composite_entry( &first_name, num_profiles, referenced_type, - notification, ); let galley = ui.painter().layout_no_wrap( description.clone(), @@ -846,7 +838,7 @@ fn render_composite_entry( let resp = ui .horizontal(|ui| { let mut options = note_options; - if notification { + if options.contains(NoteOptions::Notifications) { options = options .difference(NoteOptions::ActionBar | NoteOptions::OptionsButton) .union(NoteOptions::NotificationPreview); @@ -947,7 +939,6 @@ fn render_repost_cluster( txn: &Transaction, underlying_note: &Note, repost: &RepostUnit, - notifications: bool, ) -> RenderEntryResponse { let profiles_to_show: Vec = repost .reposts @@ -967,7 +958,6 @@ fn render_repost_cluster( underlying_note, profiles_to_show, CompositeType::Repost, - notifications, ) } diff --git a/crates/notedeck_ui/src/note/options.rs b/crates/notedeck_ui/src/note/options.rs index 3053ff78cf9e..c37d9c4f30d4 100644 --- a/crates/notedeck_ui/src/note/options.rs +++ b/crates/notedeck_ui/src/note/options.rs @@ -41,6 +41,9 @@ bitflags! { /// Styled for a notification preview const NotificationPreview = 1 << 18; + + /// Render as notification + const Notification = 1 << 19; } }