a fledgling visible library system

Why do I write these weird commit messages....
This commit is contained in:
Chris Cochrun 2025-01-14 15:03:59 -06:00
parent 201e9dc925
commit 89294061b7
7 changed files with 188 additions and 55 deletions

View file

@ -9,7 +9,10 @@ use tracing::error;
use crate::{Background, Slide, SlideBuilder, TextAlignment};
use super::{model::Model, service_items::ServiceTrait};
use super::{
model::{get_db, LibraryKind, Model},
service_items::ServiceTrait,
};
#[derive(
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize,
@ -131,11 +134,23 @@ impl FromRow<'_, SqliteRow> for Presentation {
}
impl Model<Presentation> {
pub async fn load_from_db(&mut self) {
pub async fn new_presentation_model(
db: &mut SqliteConnection,
) -> Self {
let mut model = Self {
items: vec![],
kind: LibraryKind::Presentation,
};
model.load_from_db(db).await;
model
}
pub async fn load_from_db(&mut self, db: &mut SqliteConnection) {
let result = query!(
r#"SELECT id as "id: i32", title, file_path as "path", html from presentations"#
)
.fetch_all(&mut self.db)
.fetch_all(db)
.await;
match result {
Ok(v) => {