feat: can add items
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-13 23:33:37 +02:00
parent 699bac7159
commit 7bdf8393b1
8 changed files with 300 additions and 54 deletions

View File

@@ -1,7 +1,8 @@
use hyperlog_core::log::{GraphItem, ItemState};
use hyperlog_core::log::ItemState;
use crate::{
services::{
create_item::{self, CreateItem, CreateItemExt},
create_root::{self, CreateRoot, CreateRootExt},
create_section::{self, CreateSection, CreateSectionExt},
},
@@ -46,13 +47,19 @@ pub enum Command {
pub struct Commander {
create_root: CreateRoot,
create_section: CreateSection,
create_item: CreateItem,
}
impl Commander {
pub fn new(create_root: CreateRoot, create_section: CreateSection) -> Self {
pub fn new(
create_root: CreateRoot,
create_section: CreateSection,
create_item: CreateItem,
) -> Self {
Self {
create_root,
create_section,
create_item,
}
}
@@ -78,7 +85,19 @@ impl Commander {
title,
description,
state,
} => todo!(),
} => {
self.create_item
.execute(create_item::Request {
root,
path,
title,
description,
state,
})
.await?;
Ok(())
}
Command::UpdateItem {
root,
path,
@@ -98,6 +117,10 @@ pub trait CommanderExt {
impl CommanderExt for SharedState {
fn commander(&self) -> Commander {
Commander::new(self.create_root_service(), self.create_section_service())
Commander::new(
self.create_root_service(),
self.create_section_service(),
self.create_item_service(),
)
}
}