]> uap-core.de Git - note.git/commitdiff
create initial notebooks when creating a new profile
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 17 May 2026 09:28:03 +0000 (11:28 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 17 May 2026 09:28:03 +0000 (11:28 +0200)
application/src/backend.rs

index 28261848051c723de2b48f6c577cf1b255914ddb..bf12ef3a30eb7a878edb98965465e273c01c51c9 100644 (file)
@@ -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<Runtime>,
@@ -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::<profile::Model, DbErr>(inserted)
         })?;