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
|
|
@ -194,10 +194,10 @@ use self::video_model::{
|
|||
pub struct Video {
|
||||
id: i32,
|
||||
title: String,
|
||||
path: String,
|
||||
start_time: f32,
|
||||
end_time: f32,
|
||||
looping: bool,
|
||||
pub path: String,
|
||||
pub start_time: f32,
|
||||
pub end_time: f32,
|
||||
pub looping: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -231,11 +231,22 @@ impl Default for VideoModelRust {
|
|||
}
|
||||
}
|
||||
|
||||
impl VideoModelRust {
|
||||
pub fn get_video(index: i32) -> Option<&Video> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
pub fn get_video(index: i32) -> color_eyre::Result<Video> {
|
||||
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!(Video, r#"SELECT id as "id: i32", title as "title!", filePath as "path!", startTime as "start_time!: f32", endTime as "end_time!: f32", loop as "looping!" from videos where id = ?"#, index).fetch_one(&mut db).await?;
|
||||
Ok(result)
|
||||
})
|
||||
}
|
||||
|
||||
impl video_model::VideoModel {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue