mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
fix: impossible to remove directories
This commit is contained in:
+1
-1
@@ -337,7 +337,7 @@ impl SoundpadGui {
|
|||||||
let delete_dir_button_response =
|
let delete_dir_button_response =
|
||||||
ui.add_sized([18.0, 18.0], delete_dir_button);
|
ui.add_sized([18.0, 18.0], delete_dir_button);
|
||||||
if delete_dir_button_response.clicked() {
|
if delete_dir_button_response.clicked() {
|
||||||
self.remove_dir(&path.clone());
|
self.app_state.dirs_to_remove.insert(path.clone());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -96,18 +96,6 @@ impl SoundpadGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_dir(&mut self, path: &PathBuf) {
|
|
||||||
self.app_state.dirs.retain(|x| x != path);
|
|
||||||
if let Some(current_dir) = &self.app_state.current_dir
|
|
||||||
&& current_dir == path
|
|
||||||
{
|
|
||||||
self.app_state.current_dir = None;
|
|
||||||
self.app_state.files.clear();
|
|
||||||
}
|
|
||||||
self.config.dirs = self.app_state.dirs.clone();
|
|
||||||
self.config.save_to_file().ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn open_dir(&mut self, path: &PathBuf) {
|
pub fn open_dir(&mut self, path: &PathBuf) {
|
||||||
self.app_state.current_dir = Some(path.clone());
|
self.app_state.current_dir = Some(path.clone());
|
||||||
match path.read_dir() {
|
match path.read_dir() {
|
||||||
|
|||||||
@@ -9,6 +9,17 @@ use std::time::{Duration, Instant};
|
|||||||
|
|
||||||
impl App for SoundpadGui {
|
impl App for SoundpadGui {
|
||||||
fn update(&mut self, ctx: &Context, _frame: &mut EFrame) {
|
fn update(&mut self, ctx: &Context, _frame: &mut EFrame) {
|
||||||
|
// Remove directories
|
||||||
|
for path in self.app_state.dirs_to_remove.drain() {
|
||||||
|
self.app_state.dirs.retain(|x| x != &path);
|
||||||
|
if let Some(current_dir) = &self.app_state.current_dir
|
||||||
|
&& current_dir == &path
|
||||||
|
{
|
||||||
|
self.app_state.current_dir = None;
|
||||||
|
self.app_state.files.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save directories if changed
|
// Save directories if changed
|
||||||
if !self.config.dirs.eq(&self.app_state.dirs) {
|
if !self.config.dirs.eq(&self.app_state.dirs) {
|
||||||
self.config.dirs = self.app_state.dirs.clone();
|
self.config.dirs = self.app_state.dirs.clone();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ pub struct AppState {
|
|||||||
|
|
||||||
pub current_dir: Option<PathBuf>,
|
pub current_dir: Option<PathBuf>,
|
||||||
pub dirs: Vec<PathBuf>,
|
pub dirs: Vec<PathBuf>,
|
||||||
|
pub dirs_to_remove: HashSet<PathBuf>,
|
||||||
|
|
||||||
pub selected_file: Option<PathBuf>,
|
pub selected_file: Option<PathBuf>,
|
||||||
pub files: HashSet<PathBuf>,
|
pub files: HashSet<PathBuf>,
|
||||||
|
|||||||
Reference in New Issue
Block a user