Skip to content

Commit

Permalink
πŸ› fix: remove unused field
Browse files Browse the repository at this point in the history
i never got warned about this before, maybe a r-a improvement
  • Loading branch information
fawni committed Aug 30, 2024
1 parent f2baced commit 926c074
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ pub struct WhispersTemplate {
/// The whispers to be rendered
pub whispers: Vec<Whisper>,

/// Whether the user is authenticated or not
pub authenticated: bool,

/// The user of the instance
pub user: User,
}

impl WhispersTemplate {
/// Returns a new template with the given whispers
pub fn new(whispers: Vec<Whisper>, authenticated: bool) -> Self {
pub fn new(whispers: Vec<Whisper>) -> Self {
Self {
whispers,
authenticated,
user: User::default(),
}
}
Expand All @@ -64,9 +60,8 @@ pub async fn home(
req: HttpRequest,
database: web::Data<Database>,
) -> Result<impl Responder, Box<dyn std::error::Error>> {
let authenticated = crate::auth::validate_cookie(&req);
// If the user is authenticated, show all whispers, otherwise only show public whispers.
let whispers = if authenticated {
let whispers = if crate::auth::validate_cookie(&req) {
database.list().await?
} else {
database.list().await?.filter()
Expand All @@ -75,7 +70,7 @@ pub async fn home(
.rev()
.collect::<Vec<Whisper>>();

Ok(WhispersTemplate::new(whispers, authenticated))
Ok(WhispersTemplate::new(whispers))
}

/// The template that renders the auth page
Expand Down

0 comments on commit 926c074

Please sign in to comment.