Skip to content

Commit 43c3e2c

Browse files
committed
chore: write session file
1 parent fbd6c52 commit 43c3e2c

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src-tauri/src/gui.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,20 +493,12 @@ async fn tick(app_handle: AppHandle, path: String) {
493493
let play_tick: bool =
494494
should_play_tick_sound(&state_guard.config, &state_guard.pomodoro);
495495

496-
eprintln!("old tick state: {:?}", state_guard.pomodoro);
497-
498-
// state_guard.pomodoro =
499-
// pomodoro::get_next_pomodoro_from_session_file(&state_guard.pomodoro)
500-
// .expect("Error when ticking pomodoro");
501-
502496
state_guard.pomodoro = pomodoro::tick_with_file_session_info(
503497
&state_guard.pomodoro,
504498
pomodoro::get_session_info(&state_guard.pomodoro.config.session_file),
505499
)
506500
.expect("Error when ticking pomodoro");
507501

508-
eprintln!("new tick state: {:?}", state_guard.pomodoro);
509-
510502
let _ = window.emit("external-message", state_guard.pomodoro.to_unborrowed());
511503

512504
tauri::async_runtime::spawn_blocking(move || {

src-tauri/src/pomodoro.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub fn write_session_file_from_pomodoro(
358358
}
359359

360360
pub fn write_session_file(session: &Session, session_file: PathBuf) -> io::Result<PathBuf> {
361-
eprintln!("[rust] creating {:?}", session_file);
361+
eprintln!("[rust] writing session file {:?}", session_file);
362362
fs::create_dir_all(session_file.clone().parent().unwrap())?;
363363
File::create(session_file.clone())?;
364364
fs::write(&session_file, format!("{}", session))?;
@@ -461,7 +461,7 @@ pub fn tick_with_file_session_info(
461461
) -> Result<Pomodoro> {
462462
let mut new_pomodoro = pomodoro.clone();
463463

464-
match session_info {
464+
let pomodoro_result = match session_info {
465465
// We have some session info from the disk
466466
Some(info) => {
467467
// @TODO: Here we need to check the consistency between the session_info that we have (coming from
@@ -528,7 +528,14 @@ pub fn tick_with_file_session_info(
528528
// File is not present on disk, it may have been deleted
529529
// so we should reset the current round
530530
None => reset_round(pomodoro),
531-
}
531+
}?;
532+
533+
write_session_file_from_pomodoro(
534+
&pomodoro_result,
535+
pomodoro_result.current_session.session_type,
536+
pomodoro_result.current_session.status,
537+
)?;
538+
Ok(pomodoro_result)
532539
}
533540

534541
pub fn is_end_of_session(pomodoro: &Pomodoro) -> bool {

0 commit comments

Comments
 (0)