Refactoring to slide_model and service_item getting the data from db

This is kinda a broken commit. There isn't any order to the adding of
the slide anymore. So it'll need to find a way of keeping track of
where all the current slides are and then insert the new ones in the
correct order while moving the others around as well.
This commit is contained in:
Chris Cochrun 2024-10-02 14:48:16 -05:00
parent 6052cd01ac
commit 2c014e242f
9 changed files with 347 additions and 604 deletions

View file

@ -197,9 +197,9 @@ use self::presentation_model::{
pub struct Presentation {
id: i32,
title: String,
html: bool,
path: String,
page_count: i32,
pub html: bool,
pub path: String,
pub page_count: i32,
}
#[derive(Debug)]
@ -233,10 +233,22 @@ impl Default for PresentationModelRust {
}
}
impl PresentationModelRust {
pub fn get_presentation(index: i32) -> Presentation {
todo!()
}
pub fn get_presentation(index: i32) -> color_eyre::Result<Presentation> {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut db = {
let mut data = dirs::data_local_dir().unwrap();
data.push("lumina");
data.push("library-db.sqlite3");
let mut db_url = String::from("sqlite://");
db_url.push_str(data.to_str().unwrap());
rt.block_on(async {
SqliteConnection::connect(&db_url).await.expect("problems")
})
};
rt.block_on(async {
let result = query_as!(Presentation, r#"SELECT id as "id: i32", title as "title!", filePath as "path!", html as "html!", pageCount as "page_count!: i32" from presentations where id = ?"#, index).fetch_one(&mut db).await?;
Ok(result)
})
}
impl presentation_model::PresentationModel {