Make fewer system calls

This commit is contained in:
Dheepak Krishnamurthy 2021-04-03 23:01:00 -06:00
parent 77fe218456
commit e405ebe810
3 changed files with 60 additions and 55 deletions

View file

@ -219,7 +219,8 @@ impl TaskwarriorTuiApp {
}
let data = String::from_utf8_lossy(&output.stdout);
let (c, kc) = task::block_on(async { try_join!(Config::new(&data), KeyConfig::new(&data)) })?;
let c = Config::new(&data)?;
let kc = KeyConfig::new(&data)?;
let (w, h) = crossterm::terminal::size()?;

View file

@ -64,7 +64,7 @@ pub struct Config {
}
impl Config {
pub async fn new(data: &str) -> Result<Self> {
pub fn new(data: &str) -> Result<Self> {
let bool_collection = Self::get_bool_collection();
let enabled = true;
@ -115,29 +115,31 @@ impl Config {
uda_style_calendar_title,
uda_style_context_active,
uda_shortcuts,
) = join!(
color,
filter,
data_location,
due,
rule_precedence_color,
uda_tick_rate,
uda_prefill_task_metadata,
uda_task_detail_prefetch,
uda_task_report_show_info,
uda_task_report_looping,
uda_selection_indicator,
uda_mark_indicator,
uda_unmark_indicator,
uda_selection_bold,
uda_selection_italic,
uda_selection_dim,
uda_selection_blink,
uda_calendar_months_per_row,
uda_style_calendar_title,
uda_style_context_active,
uda_shortcuts,
);
) = task::block_on(async {
join!(
color,
filter,
data_location,
due,
rule_precedence_color,
uda_tick_rate,
uda_prefill_task_metadata,
uda_task_detail_prefetch,
uda_task_report_show_info,
uda_task_report_looping,
uda_selection_indicator,
uda_mark_indicator,
uda_unmark_indicator,
uda_selection_bold,
uda_selection_italic,
uda_selection_dim,
uda_selection_blink,
uda_calendar_months_per_row,
uda_style_calendar_title,
uda_style_context_active,
uda_shortcuts,
)
});
let color = color?;
let uda_style_calendar_title = uda_style_calendar_title.unwrap_or_default();

View file

@ -92,13 +92,13 @@ impl Default for KeyConfig {
}
impl KeyConfig {
pub async fn new(data: &str) -> Result<Self> {
pub fn new(data: &str) -> Result<Self> {
let mut kc = Self::default();
kc.update(data).await?;
kc.update(data)?;
Ok(kc)
}
pub async fn update(&mut self, data: &str) -> Result<()> {
pub fn update(&mut self, data: &str) -> Result<()> {
let quit = self.get_config("uda.taskwarrior-tui.keyconfig.quit", data);
let refresh = self.get_config("uda.taskwarrior-tui.keyconfig.refresh", data);
let go_to_bottom = self.get_config("uda.taskwarrior-tui.keyconfig.go-to-bottom", data);
@ -151,33 +151,35 @@ impl KeyConfig {
context_menu,
next_tab,
previous_tab,
) = join!(
quit,
refresh,
go_to_bottom,
go_to_top,
down,
up,
page_down,
page_up,
delete,
done,
start_stop,
select,
select_all,
undo,
edit,
modify,
shell,
log,
add,
annotate,
filter,
zoom,
context_menu,
next_tab,
previous_tab,
);
) = task::block_on(async {
join!(
quit,
refresh,
go_to_bottom,
go_to_top,
down,
up,
page_down,
page_up,
delete,
done,
start_stop,
select,
select_all,
undo,
edit,
modify,
shell,
log,
add,
annotate,
filter,
zoom,
context_menu,
next_tab,
previous_tab,
)
});
self.quit = quit.unwrap_or(self.quit);
self.refresh = refresh.unwrap_or(self.refresh);