From 8a29f30fb2a949c03b318c4f7699136a8001be37 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 13 Feb 2022 12:17:00 +0100 Subject: Synchronize deck only if necessary Look at the modification time of the deck, and synchronize if it has been modified after the last deck read. --- src/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 44def4e..3e3e741 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod model; mod space_repetition; mod util; +use crate::util::event::Events; use anyhow::Result; use std::path::PathBuf; use structopt::StructOpt; @@ -17,12 +18,13 @@ struct Opt { } fn main() -> Result<()> { - let deck = Opt::from_args().deck; - let conn = db::db::init(db_path(&deck))?; - let entries = deck::read(&deck)?; - db::db::synchronize(&conn, entries)?; - let deck_name = deck::pp_from_path(&deck).unwrap_or("Deck".to_string()); - gui::gui::start(&conn, &deck_name) + let deck_path = Opt::from_args().deck; + let conn = db::db::init(db_path(&deck_path))?; + let deck_name = deck::pp_from_path(&deck_path).unwrap_or("Deck".to_string()); + let mut term = gui::gui::terminal()?; + let events = Events::new(); + gui::gui::synchronize(&conn, &mut term, &events, &deck_path, &deck_name)?; + gui::gui::start(&conn, &mut term, &events, &deck_name) } fn db_path(deck_path: &String) -> String { -- cgit v1.2.3