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
36
src/app.rs
36
src/app.rs
|
|
@ -3599,14 +3599,16 @@ impl Application for App {
|
||||||
self.config
|
self.config
|
||||||
.sort_names
|
.sort_names
|
||||||
.insert(location, (heading_options, direction));
|
.insert(location, (heading_options, direction));
|
||||||
self.must_save_sort_names = true;
|
if !self.must_save_sort_names {
|
||||||
return cosmic::Task::perform(
|
self.must_save_sort_names = true;
|
||||||
async move {
|
return cosmic::Task::perform(
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
async move {
|
||||||
cosmic::action::app(Message::SaveSortNames)
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
},
|
cosmic::action::app(Message::SaveSortNames)
|
||||||
|x| x,
|
},
|
||||||
);
|
|x| x,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4227,17 +4229,13 @@ 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.set::<HashMap<String, (HeadingOptions, bool)>>(
|
||||||
if let Err(err) = config_handler
|
"sort_names",
|
||||||
.set::<HashMap<String, (HeadingOptions, bool)>>(
|
self.config.sort_names.clone(),
|
||||||
"sort_names",
|
) {
|
||||||
self.config.sort_names.clone(),
|
log::warn!("Failed to save sort names: {:?}", err);
|
||||||
)
|
|
||||||
{
|
|
||||||
log::warn!("Failed to save sort names: {:?}", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue