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
|
||||
.sort_names
|
||||
.insert(location, (heading_options, direction));
|
||||
if !self.must_save_sort_names {
|
||||
self.must_save_sort_names = true;
|
||||
return cosmic::Task::perform(
|
||||
async move {
|
||||
|
|
@ -3610,6 +3611,7 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Task::batch(commands);
|
||||
}
|
||||
Message::TabNew => {
|
||||
|
|
@ -4227,21 +4229,17 @@ impl Application for App {
|
|||
));
|
||||
}
|
||||
Message::SaveSortNames => {
|
||||
if self.must_save_sort_names {
|
||||
self.must_save_sort_names = false;
|
||||
if let Some(config_handler) = self.config_handler.as_ref() {
|
||||
if let Err(err) = config_handler
|
||||
.set::<HashMap<String, (HeadingOptions, bool)>>(
|
||||
if let Err(err) = config_handler.set::<HashMap<String, (HeadingOptions, bool)>>(
|
||||
"sort_names",
|
||||
self.config.sort_names.clone(),
|
||||
)
|
||||
{
|
||||
) {
|
||||
log::warn!("Failed to save sort names: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue