From 08ca9208192be14acffbd24fb1fcca8497c0fb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 22 Apr 2024 18:06:09 +0200 Subject: [PATCH] Simplify conditions to render poll status icons We were using a redundant `elsif` instead of an `else`. We were also using a negative condition in the main `if`, which made the code a bit harder to read. Since we usually use `current_user` instead of `user_signed_in?`, we're also changing that for consistency.Extract component to render the status of a poll --- app/components/polls/poll_component.html.erb | 10 +++++----- app/components/polls/poll_component.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/polls/poll_component.html.erb b/app/components/polls/poll_component.html.erb index 6e52866ce..9852c1b30 100644 --- a/app/components/polls/poll_component.html.erb +++ b/app/components/polls/poll_component.html.erb @@ -1,9 +1,5 @@
- <% if !user_signed_in? %> -
"> - <%= t("polls.index.not_logged_in") %> -
- <% elsif user_signed_in? %> + <% if current_user %> <% if current_user.unverified? %>
"> <%= t("polls.index.unverified") %> @@ -17,6 +13,10 @@ <%= t("polls.index.already_answer") %>
<% end %> + <% else %> +
"> + <%= t("polls.index.not_logged_in") %> +
<% end %>
diff --git a/app/components/polls/poll_component.rb b/app/components/polls/poll_component.rb index 45aae8da8..ed0374b53 100644 --- a/app/components/polls/poll_component.rb +++ b/app/components/polls/poll_component.rb @@ -1,6 +1,6 @@ class Polls::PollComponent < ApplicationComponent attr_reader :poll - use_helpers :cannot?, :user_signed_in?, :current_user, :link_to_poll + use_helpers :cannot?, :current_user, :link_to_poll def initialize(poll) @poll = poll