diff --git a/backend/src/html_templates.rs b/backend/src/html_templates.rs index d5fd3fd..58baac7 100644 --- a/backend/src/html_templates.rs +++ b/backend/src/html_templates.rs @@ -8,9 +8,9 @@ use crate::{ }; pub struct Recipes { - pub public: Vec<(i64, String)>, - pub private: Vec<(i64, String)>, - pub current_id: Option, + public: Vec<(i64, String)>, + private: Vec<(i64, String)>, + current_id: Option, } impl Recipes { @@ -18,6 +18,7 @@ impl Recipes { connection: db::Connection, user: &Option, lang: &str, + current_id: Option, ) -> Result { Ok(Recipes { public: connection @@ -28,7 +29,7 @@ impl Recipes { } else { vec![] }, - current_id: None, + current_id, }) } diff --git a/backend/src/log.rs b/backend/src/log.rs index 8842aa7..9fe4a90 100644 --- a/backend/src/log.rs +++ b/backend/src/log.rs @@ -6,7 +6,6 @@ use std::{ }; use itertools::Itertools; -use tracing::{Level, event}; use tracing_appender::{ non_blocking::WorkerGuard, rolling::{RollingFileAppender, Rotation}, diff --git a/backend/src/services/fragments.rs b/backend/src/services/fragments.rs index e89822b..75f675e 100644 --- a/backend/src/services/fragments.rs +++ b/backend/src/services/fragments.rs @@ -22,8 +22,13 @@ pub async fn recipes_list_fragments( ) -> Result { Ok(Html( RecipesListFragmentTemplate { - recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code()) - .await?, + recipes: Recipes::new( + connection, + &context.user, + context.tr.current_lang_code(), + current_recipe.current_recipe_id, + ) + .await?, context, } .render()?, diff --git a/backend/src/services/mod.rs b/backend/src/services/mod.rs index 3483809..f44e0a9 100644 --- a/backend/src/services/mod.rs +++ b/backend/src/services/mod.rs @@ -53,8 +53,13 @@ pub async fn home_page( ) -> Result { Ok(Html( HomeTemplate { - recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code()) - .await?, + recipes: Recipes::new( + connection, + &context.user, + context.tr.current_lang_code(), + None, + ) + .await?, context, } .render()?, @@ -79,8 +84,13 @@ pub async fn dev_panel( if context.user.is_some() && context.user.as_ref().unwrap().is_admin { Ok(Html( DevPanelTemplate { - recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code()) - .await?, + recipes: Recipes::new( + connection, + &context.user, + context.tr.current_lang_code(), + None, + ) + .await?, context, log, current_log_file: log_file.log_file.clone(), diff --git a/backend/src/services/recipe.rs b/backend/src/services/recipe.rs index 017825d..4310b18 100644 --- a/backend/src/services/recipe.rs +++ b/backend/src/services/recipe.rs @@ -4,7 +4,6 @@ use axum::{ extract::{Extension, Path, State}, response::{Html, IntoResponse, Redirect, Response}, }; -// use tracing::{event, Level}; use crate::{ Context, Result, @@ -49,6 +48,7 @@ pub async fn edit( connection, &context.user, context.tr.current_lang_code(), + Some(recipe_id), ) .await?, context, @@ -112,6 +112,7 @@ pub async fn view( connection, &context.user, context.tr.current_lang_code(), + Some(recipe_id), ) .await?, context,