diff --git a/crates/ui-egui/src/panels/comments_panel.rs b/crates/ui-egui/src/panels/comments_panel.rs index 0a98762af0..74d3b4974d 100644 --- a/crates/ui-egui/src/panels/comments_panel.rs +++ b/crates/ui-egui/src/panels/comments_panel.rs @@ -160,7 +160,7 @@ fn reviewer_statuses(states: &ReviewStates<'_>, a: &Annotation) -> Vec craft::review::CommentMessage { +fn message(doc: &pdfcraft_engine::Document, a: &Annotation) -> craft::review::CommentMessage { craft::review::CommentMessage { author: a.author.clone().unwrap_or_default(), created: a.modified.as_deref().and_then(pdf_date_seconds).unwrap_or(0), @@ -168,6 +168,7 @@ fn message(a: &Annotation) -> craft::review::CommentMessage { text: a.contents.clone().unwrap_or_default(), reactions: Vec::new(), read: true, + deletable: doc.annotation_deletable(a.page, a.index), } } @@ -198,10 +199,10 @@ fn threads(doc: &pdfcraft_engine::Document, prefs: &CommentPrefs) -> (Vec, wake: Wake) -> impl FnMut(&mut egui::Ui, &mut SignatureDraft, Option) + Send + 'static { +pub(crate) fn tab(host: Arc, wake: Wake) -> impl FnMut(&mut egui::Ui, &mut SignatureDraft, craft::review::ui::ScanEvent) + Send + 'static { let queue = JobQueue::new(host.jobs_shared().clone(), wake, QueueOptions::default()); let mut state = ScanTabState { host, scan: None, preview: None, shown: None, pick: None, queue, request: 0, view: unfitted(), error: None }; - move |ui, draft, dropped| state.show(ui, draft, dropped) + move |ui, draft, event| match event { + craft::review::ui::ScanEvent::Show(dropped) => state.show(ui, draft, dropped), + craft::review::ui::ScanEvent::Clear => { + if let Some(id) = state.pick.take() { + state.host.files().forget(id); + } + state.queue.reprioritize(|_, _| None); + state.request = state.request.wrapping_add(1); + state.scan = None; + state.preview = None; + state.shown = None; + state.view = unfitted(); + state.error = None; + } + } }