refactor: avoid task for save sort names when debouncing

This commit is contained in:
Ashley Wulber 2025-07-03 09:57:26 -04:00 • committed by Jeremy Soller
parent 01bf55865c
commit 499ce1a7ec

View file

@ -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()
}