set scroll offset when routing to thread
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -93,7 +93,15 @@ fn execute_note_action(
|
|||||||
};
|
};
|
||||||
|
|
||||||
timeline_res = threads
|
timeline_res = threads
|
||||||
.open(ndb, txn, pool, &thread_selection, preview, col)
|
.open(
|
||||||
|
ndb,
|
||||||
|
txn,
|
||||||
|
pool,
|
||||||
|
&thread_selection,
|
||||||
|
preview,
|
||||||
|
col,
|
||||||
|
scroll_offset,
|
||||||
|
)
|
||||||
.map(NotesOpenResult::Thread);
|
.map(NotesOpenResult::Thread);
|
||||||
|
|
||||||
let route = Route::Thread(thread_selection);
|
let route = Route::Thread(thread_selection);
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ pub struct Threads {
|
|||||||
impl Threads {
|
impl Threads {
|
||||||
/// Opening a thread.
|
/// Opening a thread.
|
||||||
/// Similar to [[super::cache::TimelineCache::open]]
|
/// Similar to [[super::cache::TimelineCache::open]]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn open(
|
pub fn open(
|
||||||
&mut self,
|
&mut self,
|
||||||
ndb: &mut Ndb,
|
ndb: &mut Ndb,
|
||||||
@@ -162,6 +163,7 @@ impl Threads {
|
|||||||
thread: &ThreadSelection,
|
thread: &ThreadSelection,
|
||||||
new_scope: bool,
|
new_scope: bool,
|
||||||
col: usize,
|
col: usize,
|
||||||
|
scroll_offset: f32,
|
||||||
) -> Option<NewThreadNotes> {
|
) -> Option<NewThreadNotes> {
|
||||||
tracing::info!("Opening thread: {:?}", thread);
|
tracing::info!("Opening thread: {:?}", thread);
|
||||||
let local_sub_filter = if let Some(selected) = &thread.selected_note {
|
let local_sub_filter = if let Some(selected) = &thread.selected_note {
|
||||||
@@ -191,7 +193,7 @@ impl Threads {
|
|||||||
RawEntryMut::Vacant(entry) => {
|
RawEntryMut::Vacant(entry) => {
|
||||||
let id = NoteId::new(*selected_note_id);
|
let id = NoteId::new(*selected_note_id);
|
||||||
|
|
||||||
let node = ThreadNode::new(ParentState::Unknown);
|
let node = ThreadNode::new(ParentState::Unknown).with_offset(scroll_offset);
|
||||||
entry.insert(id, node);
|
entry.insert(id, node);
|
||||||
|
|
||||||
&local_sub_filter
|
&local_sub_filter
|
||||||
|
|||||||
@@ -52,17 +52,26 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible);
|
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible);
|
||||||
|
|
||||||
let offset_id = scroll_id.with(("scroll_offset", self.selected_note_id));
|
if let Some(thread) = self.threads.threads.get_mut(&self.selected_note_id) {
|
||||||
|
if let Some(new_offset) = thread.set_scroll_offset.take() {
|
||||||
if let Some(offset) = ui.data(|i| i.get_temp::<f32>(offset_id)) {
|
scroll_area = scroll_area.vertical_scroll_offset(new_offset);
|
||||||
scroll_area = scroll_area.vertical_scroll_offset(offset);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = scroll_area.show(ui, |ui| self.notes(ui, &txn));
|
let output = scroll_area.show(ui, |ui| self.notes(ui, &txn));
|
||||||
|
|
||||||
ui.data_mut(|d| d.insert_temp(offset_id, output.state.offset.y));
|
let mut resp = output.inner;
|
||||||
|
|
||||||
output.inner
|
if let Some(NoteAction::Note {
|
||||||
|
note_id: _,
|
||||||
|
preview: _,
|
||||||
|
scroll_offset,
|
||||||
|
}) = &mut resp
|
||||||
|
{
|
||||||
|
*scroll_offset = output.state.offset.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
resp
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notes(&mut self, ui: &mut egui::Ui, txn: &Transaction) -> Option<NoteAction> {
|
fn notes(&mut self, ui: &mut egui::Ui, txn: &Transaction) -> Option<NoteAction> {
|
||||||
|
|||||||
Reference in New Issue
Block a user