diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs index 21ba6133..398c1edc 100644 --- a/crates/notedeck_columns/src/timeline/route.rs +++ b/crates/notedeck_columns/src/timeline/route.rs @@ -87,8 +87,8 @@ pub fn render_thread_route( note_options, note_context, jobs, + col, ) - .id_source(col) .ui(ui) .map(Into::into) } diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs index f74a1337..2fe3db44 100644 --- a/crates/notedeck_columns/src/ui/thread.rs +++ b/crates/notedeck_columns/src/ui/thread.rs @@ -14,7 +14,6 @@ pub struct ThreadView<'a, 'd> { selected_note_id: &'a [u8; 32], note_options: NoteOptions, col: usize, - id_source: egui::Id, note_context: &'a mut NoteContext<'d>, jobs: &'a mut JobsCache, } @@ -27,37 +26,33 @@ impl<'a, 'd> ThreadView<'a, 'd> { note_options: NoteOptions, note_context: &'a mut NoteContext<'d>, jobs: &'a mut JobsCache, + col: usize, ) -> Self { - let id_source = egui::Id::new("threadscroll_threadview"); ThreadView { threads, selected_note_id, note_options, - id_source, note_context, jobs, - col: 0, + col, } } - pub fn id_source(mut self, col: usize) -> Self { - self.col = col; - self.id_source = egui::Id::new(("threadscroll", col)); - self + pub fn scroll_id(selected_note_id: &[u8; 32], col: usize) -> egui::Id { + egui::Id::new(("threadscroll", selected_note_id, col)) } pub fn ui(&mut self, ui: &mut egui::Ui) -> Option { let txn = Transaction::new(self.note_context.ndb).expect("txn"); + let scroll_id = ThreadView::scroll_id(self.selected_note_id, self.col); let mut scroll_area = egui::ScrollArea::vertical() - .id_salt(self.id_source) + .id_salt(scroll_id) .animated(false) .auto_shrink([false, false]) .scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible); - let offset_id = self - .id_source - .with(("scroll_offset", self.selected_note_id)); + let offset_id = scroll_id.with(("scroll_offset", self.selected_note_id)); if let Some(offset) = ui.data(|i| i.get_temp::(offset_id)) { scroll_area = scroll_area.vertical_scroll_offset(offset);