fix(pomodoro): ctrl+r resets rounds + both clocks (#83)
This commit is contained in:
parent
5f4c5bb8ed
commit
d27587a44a
@ -8,6 +8,7 @@
|
||||
|
||||
### Fixes
|
||||
|
||||
- (pomodoro) `ctrl+r` resets rounds AND both clocks [#83](https://github.com/sectore/tick-tock-tui/pull/83)
|
||||
- (pomodoro) reset active clock only [#82](https://github.com/sectore/tick-tock-tui/pull/82)
|
||||
|
||||
## v1.3.0 - 2025-05-06
|
||||
|
||||
@ -158,12 +158,12 @@ impl StatefulWidget for Footer {
|
||||
}
|
||||
spans.extend_from_slice(&[
|
||||
Span::from(SPACE),
|
||||
Span::from("[r]eset"),
|
||||
Span::from("[r]eset clock"),
|
||||
]);
|
||||
if self.selected_content == Content::Pomodoro {
|
||||
spans.extend_from_slice(&[
|
||||
Span::from(SPACE),
|
||||
Span::from("[^r]eset round"),
|
||||
Span::from("[^r]eset clocks+rounds"),
|
||||
]);
|
||||
}
|
||||
spans
|
||||
|
||||
@ -107,10 +107,18 @@ impl PomodoroState {
|
||||
&self.clock_map.work
|
||||
}
|
||||
|
||||
pub fn get_clock_work_mut(&mut self) -> &mut ClockState<Countdown> {
|
||||
self.clock_map.get_mut(&Mode::Work)
|
||||
}
|
||||
|
||||
pub fn get_clock_pause(&self) -> &ClockState<Countdown> {
|
||||
&self.clock_map.pause
|
||||
}
|
||||
|
||||
pub fn get_clock_pause_mut(&mut self) -> &mut ClockState<Countdown> {
|
||||
self.clock_map.get_mut(&Mode::Pause)
|
||||
}
|
||||
|
||||
pub fn get_mode(&self) -> &Mode {
|
||||
&self.mode
|
||||
}
|
||||
@ -198,13 +206,15 @@ impl TuiEventHandler for PomodoroState {
|
||||
KeyCode::Right => {
|
||||
self.next();
|
||||
}
|
||||
// reset round
|
||||
// reset rounds AND clocks
|
||||
KeyCode::Char('r') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.round = 1;
|
||||
self.get_clock_work_mut().reset();
|
||||
self.get_clock_pause_mut().reset();
|
||||
}
|
||||
// reset values
|
||||
// reset current clock
|
||||
KeyCode::Char('r') => {
|
||||
// count number of finished rounds of WORK before resetting the clock
|
||||
// increase round before (!!) resetting the clock
|
||||
if self.get_mode() == &Mode::Work && self.get_clock().is_done() {
|
||||
self.round += 1;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user