Skip to content

Commit

Permalink
Use entries from the state contained in the parent app
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 5, 2019
1 parent 8f3daee commit 03d2ee3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/interactive/widgets/entries.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::interactive::{
sorted_entries,
widgets::{fill_background_to_right, List, ListState},
DisplayOptions, EntryDataBundle, SortMode,
DisplayOptions, EntryDataBundle,
};
use dua::traverse::{Tree, TreeIndex};
use itertools::Itertools;
Expand All @@ -17,9 +16,9 @@ pub struct Entries<'a, 'b> {
pub tree: &'a Tree,
pub root: TreeIndex,
pub display: DisplayOptions,
pub sorting: SortMode,
pub selected: Option<TreeIndex>,
pub list_state: &'b mut ListState,
pub entries: &'a [EntryDataBundle],
pub border_style: Style,
pub is_focussed: bool,
}
Expand All @@ -30,7 +29,7 @@ impl<'a, 'b> Widget for Entries<'a, 'b> {
tree,
root,
display,
sorting,
entries,
selected,
border_style,
list_state,
Expand All @@ -41,11 +40,9 @@ impl<'a, 'b> Widget for Entries<'a, 'b> {
.next()
.is_none()
};
let path_of = |node_idx| dua::path_of(tree, node_idx);

let entries = sorted_entries(tree, *root, *sorting);
let total: u64 = entries.iter().map(|b| b.data.size).sum();
let title = match path_of(*root).to_string_lossy().to_string() {
let title = match dua::path_of(tree, *root).to_string_lossy().to_string() {
ref p if p.is_empty() => Path::new(".")
.canonicalize()
.map(|p| p.to_string_lossy().to_string())
Expand Down
2 changes: 1 addition & 1 deletion src/interactive/widgets/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<'a, 'b, 'c> Widget for MainWindow<'a, 'b, 'c> {
tree: &tree,
root: state.root,
display: *display,
sorting: state.sorting,
entries: &state.entries,
selected: state.selected,
border_style: entries_style,
list_state: &mut draw_state.entries_list,
Expand Down

0 comments on commit 03d2ee3

Please sign in to comment.