refactor: avoid task for save sort names when debouncing
This commit is contained in:
parent
01bf55865c
commit
499ce1a7ec
1 changed files with 17 additions and 19 deletions
10
src/app.rs
10
src/app.rs
|
|
@ -3599,6 +3599,7 @@ impl Application for App {
|
||||||
self.config
|
self.config
|
||||||
.sort_names
|
.sort_names
|
||||||
.insert(location, (heading_options, direction));
|
.insert(location, (heading_options, direction));
|
||||||
|
if !self.must_save_sort_names {
|
||||||
self.must_save_sort_names = true;
|
self.must_save_sort_names = true;
|
||||||
return cosmic::Task::perform(
|
return cosmic::Task::perform(
|
||||||
async move {
|
async move {
|
||||||
|
|
@ -3610,6 +3611,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Task::batch(commands);
|
return Task::batch(commands);
|
||||||
}
|
}
|
||||||
Message::TabNew => {
|
Message::TabNew => {
|
||||||
|
|
@ -4227,21 +4229,17 @@ impl Application for App {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Message::SaveSortNames => {
|
Message::SaveSortNames => {
|
||||||
if self.must_save_sort_names {
|
|
||||||
self.must_save_sort_names = false;
|
self.must_save_sort_names = false;
|
||||||
if let Some(config_handler) = self.config_handler.as_ref() {
|
if let Some(config_handler) = self.config_handler.as_ref() {
|
||||||
if let Err(err) = config_handler
|
if let Err(err) = config_handler.set::<HashMap<String, (HeadingOptions, bool)>>(
|
||||||
.set::<HashMap<String, (HeadingOptions, bool)>>(
|
|
||||||
"sort_names",
|
"sort_names",
|
||||||
self.config.sort_names.clone(),
|
self.config.sort_names.clone(),
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
log::warn!("Failed to save sort names: {:?}", err);
|
log::warn!("Failed to save sort names: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue