From: Olaf Wintermann Date: Sun, 17 May 2026 09:28:03 +0000 (+0200) Subject: create initial notebooks when creating a new profile X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=42852ccdba8f36b8b005eff8ebf53a65551aa1d6;p=note.git create initial notebooks when creating a new profile --- diff --git a/application/src/backend.rs b/application/src/backend.rs index 2826184..bf12ef3 100644 --- a/application/src/backend.rs +++ b/application/src/backend.rs @@ -10,7 +10,7 @@ use ui_rs::ui; use entity::{collection, profile}; use entity::profile::Entity as Profile; -use entity::collection::Entity as Collection; +use entity::collection::{CollectionType, Entity as Collection}; pub struct Backend { rt: Arc, @@ -110,6 +110,29 @@ impl Backend { let inserted = active.insert(&self.db).await?; + // create some initial notebooks + let insert_notebooks = collection::ActiveModel { + profile_id: Set(inserted.id), + name: Set("Notebooks".to_string()), + parent: Set("".to_string()), + icon: Set("".to_string()), + kind: Set(CollectionType::Notebook), + + ..Default::default() + }; + let notebooks = insert_notebooks.insert(&self.db).await?; + + let insert_notes = collection::ActiveModel { + profile_id: Set(inserted.id), + name: Set("Notes".to_string()), + parent: Set("/Notebooks".to_string()), + icon: Set("".to_string()), + kind: Set(CollectionType::Notebook), + + ..Default::default() + }; + insert_notes.insert(&self.db).await?; + Ok::(inserted) })?;