@@ -3,7 +3,7 @@ use super::session_timers::{RestTimerDisplay, SessionDurationDisplay};
33use crate :: components:: CompletedExerciseLog ;
44use crate :: models:: {
55 get_current_timestamp, parse_distance_km, parse_weight_kg, Category , ExerciseLog , Force ,
6- WorkoutSession ,
6+ WorkoutSession , HG_PER_KG , M_PER_KM ,
77} ;
88use crate :: services:: exercise_db:: {
99 detect_filter_suggestions, exercise_matches_filters, SearchFilter ,
@@ -21,6 +21,8 @@ const SEARCH_DEBOUNCE_MS: u32 = 200;
2121const MAX_FILTER_ONLY_RESULTS : usize = 20 ;
2222/// Maximum exercises shown from the full database when a text search query is active.
2323const MAX_TEXT_SEARCH_RESULTS : usize = 10 ;
24+ /// Default rest time in seconds offered to the user in the rest input form.
25+ const DEFAULT_REST_SECONDS : u64 = 30 ;
2426/// Prefill the weight / reps / distance inputs from the last recorded log for
2527/// `exercise_id`, or clear them if no prior log exists.
2628///
@@ -51,7 +53,7 @@ fn prefill_inputs_from_last_log(
5153 if use_active {
5254 if let Some ( last_log) = active_log {
5355 if let Some ( w) = last_log. weight_hg {
54- weight_input. set ( format ! ( "{:.1}" , f64 :: from( w. 0 ) / 10.0 ) ) ;
56+ weight_input. set ( format ! ( "{:.1}" , f64 :: from( w. 0 ) / HG_PER_KG ) ) ;
5557 } else {
5658 weight_input. set ( String :: new ( ) ) ;
5759 }
@@ -61,7 +63,7 @@ fn prefill_inputs_from_last_log(
6163 reps_input. set ( String :: new ( ) ) ;
6264 }
6365 if let Some ( d) = last_log. distance_m {
64- distance_input. set ( format ! ( "{:.2}" , f64 :: from( d. 0 ) / 1000.0 ) ) ;
66+ distance_input. set ( format ! ( "{:.2}" , f64 :: from( d. 0 ) / M_PER_KM ) ) ;
6567 } else {
6668 distance_input. set ( String :: new ( ) ) ;
6769 }
@@ -74,7 +76,7 @@ fn prefill_inputs_from_last_log(
7476 } else {
7577 // Use values from the most-recently completed cross-session log.
7678 if let Some ( w) = bests. last_weight_hg {
77- weight_input. set ( format ! ( "{:.1}" , f64 :: from( w. 0 ) / 10.0 ) ) ;
79+ weight_input. set ( format ! ( "{:.1}" , f64 :: from( w. 0 ) / HG_PER_KG ) ) ;
7880 } else {
7981 weight_input. set ( String :: new ( ) ) ;
8082 }
@@ -84,7 +86,7 @@ fn prefill_inputs_from_last_log(
8486 reps_input. set ( String :: new ( ) ) ;
8587 }
8688 if let Some ( d) = bests. last_distance_m {
87- distance_input. set ( format ! ( "{:.2}" , f64 :: from( d. 0 ) / 1000.0 ) ) ;
89+ distance_input. set ( format ! ( "{:.2}" , f64 :: from( d. 0 ) / M_PER_KM ) ) ;
8890 } else {
8991 distance_input. set ( String :: new ( ) ) ;
9092 }
@@ -620,7 +622,7 @@ pub fn GlobalSessionHeader() -> Element {
620622 let session = use_memo ( move || sessions. read ( ) . iter ( ) . find ( |s| s. is_active ( ) ) . cloned ( ) ) ;
621623 let mut show_rest = use_context :: < crate :: ShowRestInputSignal > ( ) . 0 ;
622624 let rest_duration = use_context :: < RestDurationSignal > ( ) . 0 ;
623- let mut rest_input_value = use_signal ( || 30u64 . to_string ( ) ) ;
625+ let mut rest_input_value = use_signal ( || DEFAULT_REST_SECONDS . to_string ( ) ) ;
624626 let mut congratulations = use_context :: < crate :: CongratulationsSignal > ( ) . 0 ;
625627 use_effect ( move || {
626628 if * show_rest. read ( ) {
0 commit comments