diff options
Diffstat (limited to 'src/gui/mod.rs')
-rw-r--r-- | src/gui/mod.rs | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 858b30d..358e4b5 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -2,12 +2,10 @@ pub mod message; pub mod question; pub mod util; -use crate::deck; -use crate::util::time; -use crate::{db, space_repetition, util::event::Events}; +use crate::{db, space_repetition, util::event::Events, util::time}; use anyhow::Result; use rusqlite::Connection; -use std::{fs, io, time::Duration}; +use std::io; use termion::{raw::IntoRawMode, raw::RawTerminal, screen::AlternateScreen}; use tui::{backend::TermionBackend, Terminal}; @@ -20,28 +18,6 @@ pub fn terminal() -> Result<Term> { Ok(Terminal::new(backend)?) } -pub fn synchronize( - conn: &Connection, - term: &mut Term, - events: &Events, - deck_path: &str, - deck_name: &str, -) -> Result<()> { - let last_modified = time::seconds_since_unix_epoch_of(fs::metadata(deck_path)?.modified()?)?; - let last_deck_read = db::last_deck_read(conn); - let must_synchronize = last_deck_read.map(|r| r < last_modified).unwrap_or(true); - - if must_synchronize { - let _ = message::show(term, events, deck_name, "Synchronization du deck…", false); - time::wait_at_least( - || db::synchronize(conn, deck::read(deck_path)?), - Duration::from_secs(1), - )?; - } - - Ok(()) -} - pub fn start(conn: &Connection, term: &mut Term, events: &Events, deck_name: &str) -> Result<()> { let mut answers = 0; @@ -66,7 +42,7 @@ pub fn start(conn: &Connection, term: &mut Term, events: &Events, deck_name: &st Some(ready) => { let duration = time::pp_duration(ready - now); format!("Prochaine carte disponible dans {duration}.") - }, + } None => "Aucune carte n’est disponible. Votre deck est-il vide ?".to_string(), }; let _ = message::show(term, events, &title, &message, true); |