Skip to content

Commit 5c2e5f3

Browse files
committed
minor: Rework IndexTemplate constructor
1 parent fa6ab36 commit 5c2e5f3

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/routes/index.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,22 @@ impl FallibleTemplate for IndexTemplate {
2525
}
2626

2727
impl IndexTemplate {
28-
pub async fn new(
29-
context: AppStateContext,
30-
status: StatusCookie,
31-
) -> Result<FlashTemplate<Self>, AppStateError> {
28+
pub async fn new(context: AppStateContext) -> Result<Self, AppStateError> {
3229
let categories = context.db.category().list().await.context(CategorySnafu)?;
3330
let children = FileSystemEntry::from_categories(&categories);
3431

35-
Ok(status.with_template(IndexTemplate {
32+
Ok(Self {
3633
state: context,
3734
flash: None,
3835
children,
39-
}))
36+
})
4037
}
4138
}
4239

4340
pub async fn index(
4441
context: AppStateContext,
4542
status: StatusCookie,
4643
) -> Result<FlashTemplate<IndexTemplate>, AppStateError> {
47-
IndexTemplate::new(context, status).await
44+
let template = IndexTemplate::new(context).await?;
45+
Ok(status.with_template(template))
4846
}

0 commit comments

Comments
 (0)