Skip to content

Commit

Permalink
feat: preserve more settings across loads
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Sep 11, 2024
1 parent c36c08e commit 5f40904
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,17 @@ impl LogViewerApp {
match Data::try_from((self.row_idx_field_name.as_ref(), &data[..])) {
Ok(mut data) => {
if let Some(old_data) = self.data.as_mut() {
// Preserve filter settings across loads of the data
data.filter = old_data.filter.take();
// Preserve settings across loads of the data
data.take_config(
old_data,
self.data_display_options.common_fields(),
);
}
self.data = Some(data);
if self.should_scroll_to_end_on_load {
self.move_selected_last();
} else {
self.should_scroll = true;
}
LoadingStatus::NotInProgress
}
Expand Down
13 changes: 13 additions & 0 deletions src/app/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ impl Data {
warn!("Apply called but no filter is available")
}
}

pub fn take_config(&mut self, other: &mut Self, common_fields: &BTreeSet<String>) {
let is_filtered = other.is_filtered();
self.filter = other.filter.take();
if is_filtered {
self.apply_filter(common_fields);
}
if let Some(i) = other.selected_row {
if i < self.len() {
self.selected_row = Some(i);
}
}
}
}

fn is_included(
Expand Down

0 comments on commit 5f40904

Please sign in to comment.