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:
parent
6052cd01ac
commit
2c014e242f
9 changed files with 347 additions and 604 deletions
|
@ -172,7 +172,7 @@ use self::image_model::{
|
|||
pub struct Image {
|
||||
id: i32,
|
||||
title: String,
|
||||
path: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -206,10 +206,22 @@ impl Default for ImageModelRust {
|
|||
}
|
||||
}
|
||||
|
||||
impl ImageModelRust {
|
||||
pub fn get_image(index: i32) -> Option<&Image> {
|
||||
todo!()
|
||||
}
|
||||
pub fn get_image(index: i32) -> color_eyre::Result<Image> {
|
||||
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!(Image, r#"SELECT id as "id: i32", title as "title!", filePath as "path!" from images where id = ?"#, index).fetch_one(&mut db).await?;
|
||||
Ok(result)
|
||||
})
|
||||
}
|
||||
|
||||
impl image_model::ImageModel {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue