summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-04-09 19:22:42 +0200
committerrabite <rabite@posteo.de>2019-04-09 19:22:42 +0200
commit1fd25d35c3b1989f6d9a243571095251bcc29535 (patch)
tree4043ea54e14fecffc2bfff4a539c96e7186ff0be
parentee3b82f85d2260509dc443cf4086858926c89ce0 (diff)
add/remove placeholder when dir becomes empty/populatedv1.0.3
-rw-r--r--src/files.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/files.rs b/src/files.rs
index f374974..0fd1ea2 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -363,10 +363,25 @@ impl Files {
new.selected = selected;
self.files.push(new);
});
+
self.sort();
+
+ if self.len() == 0 {
+ let placeholder = File::new_placeholder(&self.directory.path)?;
+ self.files.push(placeholder);
+ } else {
+ self.remove_placeholder();
+ }
+
Ok(())
}
+ fn remove_placeholder(&mut self) {
+ let dirpath = self.directory.path.clone();
+ self.find_file_with_path(&dirpath).cloned()
+ .map(|placeholder| self.files.remove_item(&placeholder));
+ }
+
pub fn handle_event(&mut self,
event: &DebouncedEvent) -> HResult<()> {
match event {