From 5cefa09f4a340ecd0c4feeca499d80cf24468e17 Mon Sep 17 00:00:00 2001 From: RanXom Date: Fri, 12 Jun 2026 22:58:50 +0530 Subject: shorten if lets using chained if lets --- src/pomo/mod.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/pomo/mod.rs') diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index be55a0d..42ce627 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -35,14 +35,14 @@ impl Pomo { let mut app = Pomo::new(); if let Some(proj_dirs) = ProjectDirs::from("", "", "pomoru") { let config_path = proj_dirs.config_dir().join("config.toml"); - if let Ok(content) = fs::read_to_string(config_path) { - if let Ok(config) = toml::from_str::(&content) { - app.work_time = Duration::from_secs(config.work_time_mins * 60); - app.short_break_time = Duration::from_secs(config.short_break_mins * 60); - app.long_break_time = Duration::from_secs(config.long_break_mins * 60); - app.tasks = config.tasks; - app.reset_timer_to_mode(); - } + if let Ok(content) = fs::read_to_string(config_path) + && let Ok(config) = toml::from_str::(&content) + { + app.work_time = Duration::from_secs(config.work_time_mins * 60); + app.short_break_time = Duration::from_secs(config.short_break_mins * 60); + app.long_break_time = Duration::from_secs(config.long_break_mins * 60); + app.tasks = config.tasks; + app.reset_timer_to_mode(); } } app @@ -67,14 +67,13 @@ impl Pomo { // Tighten poll to 16ms (~60fps feel) for input responsiveness event_res = tokio::task::spawn_blocking(|| event::poll(Duration::from_millis(16))) => { - if let Ok(Ok(true)) = event_res { - if let Ok(Event::Key(key)) = event::read() { - if key.kind == event::KeyEventKind::Press { - self.handle_key(key); - } - } + if let Ok(Ok(true)) = event_res + && let Ok(Event::Key(key)) = event::read() + && key.kind == event::KeyEventKind::Press + { + self.handle_key(key); } - } + } } if self.should_quit { -- cgit v1.2.3 From bb9688d43051c19cc2dc697389547470d8c18f62 Mon Sep 17 00:00:00 2001 From: RanXom Date: Fri, 12 Jun 2026 23:15:51 +0530 Subject: Handle session switch manage on timer expiration --- src/pomo/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pomo/mod.rs') diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index 42ce627..cd7a663 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -110,6 +110,9 @@ impl Pomo { } } + (AppScreen::Timer, KeyCode::Char('a')) => { + self.auto_switch_sessions = !self.auto_switch_sessions + } (AppScreen::Timer, KeyCode::Char('t')) => self.screen = AppScreen::Tasks, (AppScreen::Timer, KeyCode::Char(' ')) => self.is_running = !self.is_running, (AppScreen::Timer, KeyCode::Char('r')) => self.time_remaining = self.work_time, -- cgit v1.2.3 From 85cb438cd0476d230667dec291022baee5793e79 Mon Sep 17 00:00:00 2001 From: RanXom Date: Fri, 12 Jun 2026 23:19:51 +0530 Subject: save auto_switch_sessions to config --- src/pomo/mod.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/pomo/mod.rs') diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index cd7a663..1d6ae34 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -18,6 +18,7 @@ impl Pomo { short_break_mins: self.short_break_time.as_secs() / 60, long_break_mins: self.long_break_time.as_secs() / 60, tasks: self.tasks.clone(), + auto_switch_sessions: self.auto_switch_sessions, }; let toml = toml::to_string_pretty(&config)?; @@ -42,6 +43,7 @@ impl Pomo { app.short_break_time = Duration::from_secs(config.short_break_mins * 60); app.long_break_time = Duration::from_secs(config.long_break_mins * 60); app.tasks = config.tasks; + app.auto_switch_sessions = config.auto_switch_sessions; app.reset_timer_to_mode(); } } -- cgit v1.2.3