Skip to content

Commit 1a12920

Browse files
authored
feat: add reset session button (#204)
1 parent 737bf0f commit 1a12920

File tree

5 files changed

+43
-7
lines changed

5 files changed

+43
-7
lines changed

main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,17 @@ input:focus {
227227
text-align: center;
228228
}
229229
.round-wrapper .total-rounds {
230+
text-align: left;
231+
}
232+
233+
.round-wrapper .reset-rounds {
230234
color: var(--color-foreground-darker);
231235
font-size: 0.7rem;
236+
letter-spacing: 0.05rem;
237+
}
238+
239+
.round-wrapper .reset-rounds p {
240+
display: inline;
232241
}
233242

234243
.icon--mute path {

src-elm/Main.elm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Types
1919
, Msg(..)
2020
, Notification
2121
, RGB(..)
22+
, ResetType(..)
2223
, Seconds
2324
, SessionStatus(..)
2425
, SessionType(..)
@@ -418,7 +419,7 @@ update msg ({ config } as model) =
418419
, sendMessageFromElm (elmMessageBuilder "update_config" newConfig configEncoder)
419420
)
420421

421-
Reset ->
422+
Reset resetType ->
422423
let
423424
currentState =
424425
{ color =
@@ -436,7 +437,18 @@ update msg ({ config } as model) =
436437
( model
437438
, Cmd.batch
438439
[ sendMessageFromElm (elmMessageBuilder "update_current_state" currentState currentStateEncoder)
439-
, sendMessageFromElm (elmMessageEncoder { name = "reset", value = Nothing })
440+
, sendMessageFromElm
441+
(elmMessageEncoder
442+
{ name =
443+
case resetType of
444+
CurrentRound ->
445+
"reset_round"
446+
447+
EntireSession ->
448+
"reset_session"
449+
, value = Nothing
450+
}
451+
)
440452
]
441453
)
442454

src-elm/Types.elm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Types exposing
1111
, PomodoroSession
1212
, PomodoroState
1313
, RGB(..)
14+
, ResetType(..)
1415
, Seconds
1516
, SessionStatus(..)
1617
, SessionType(..)
@@ -59,7 +60,7 @@ type Msg
5960
| ProcessExternalMessage ExternalMessage
6061
| MinimizeWindow
6162
| NoOp
62-
| Reset
63+
| Reset ResetType
6364
| ResetSettings
6465
| ResetAudioFile SessionType
6566
| SkipCurrentRound
@@ -71,6 +72,11 @@ type Msg
7172
| UpdateVolume String
7273

7374

75+
type ResetType
76+
= CurrentRound
77+
| EntireSession
78+
79+
7480
type alias Seconds =
7581
Int
7682

src-elm/View/Timer.elm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Svg exposing (path, svg)
88
import Svg.Attributes as SvgAttr
99
import Themes exposing (Theme)
1010
import TimeHelper exposing (getCurrentMaxTime)
11-
import Types exposing (Model, Msg(..), RGB(..), Seconds, SessionStatus(..), SessionType(..))
11+
import Types exposing (Model, Msg(..), RGB(..), ResetType(..), Seconds, SessionStatus(..), SessionType(..))
1212

1313

1414
dialView : SessionType -> Seconds -> Seconds -> Float -> Theme -> String -> String -> String -> Html Msg
@@ -189,8 +189,12 @@ footerView : Model -> Html Msg
189189
footerView model =
190190
section [ class "container", class "footer" ]
191191
[ div [ class "round-wrapper" ]
192-
[ p [] [ text <| String.fromInt (model.pomodoroState |> Maybe.map (\state -> state.currentWorkRoundNumber) |> Maybe.withDefault 1) ++ "/" ++ String.fromInt model.config.maxRoundNumber ]
193-
, p [ class "text-button", title "Reset current round", onClick Reset ] [ text "Reset" ]
192+
[ p [ class "total-rounds" ] [ text <| String.fromInt (model.pomodoroState |> Maybe.map (\state -> state.currentWorkRoundNumber) |> Maybe.withDefault 1) ++ "/" ++ String.fromInt model.config.maxRoundNumber ]
193+
, div [ class "reset-rounds" ]
194+
[ p [ class "text-button", title "Reset current round", onClick <| Reset CurrentRound ] [ text "Reset round" ]
195+
, text " or "
196+
, p [ class "text-button", title "Reset the whole session", onClick <| Reset EntireSession ] [ text "session" ]
197+
]
194198
]
195199
, div [ class "icon-group", style "position" "absolute", style "right" "0px" ]
196200
[ div [ class "icon-wrapper", class "icon-wrapper--double--left", title "Skip the current round", onClick SkipCurrentRound ]

src-tauri/src/gui.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,14 @@ async fn handle_external_message<R: tauri::Runtime>(
792792
"quit" => {
793793
app.exit(0);
794794
}
795-
"reset" => {
795+
"reset_round" => {
796796
app_state_guard.pomodoro = pomodoro::reset(&app_state_guard.pomodoro);
797797
}
798+
"reset_session" => {
799+
app_state_guard.pomodoro = pomodoro::reset(&app_state_guard.pomodoro);
800+
app_state_guard.pomodoro.current_work_round_number = 1;
801+
}
802+
798803
"skip" => {
799804
app_state_guard.pomodoro = pomodoro::next(&app_state_guard.pomodoro);
800805
}

0 commit comments

Comments
 (0)