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
This commit is contained in:
Javi Martín
2024-04-22 18:06:09 +02:00
parent 765ab758dc
commit 08ca920819
2 changed files with 6 additions and 6 deletions

View File

@@ -1,9 +1,5 @@
<div class="poll with-image">
<% if !user_signed_in? %>
<div class="icon-poll-answer not-logged-in" title="<%= t("polls.index.not_logged_in") %>">
<span class="show-for-sr"><%= t("polls.index.not_logged_in") %></span>
</div>
<% elsif user_signed_in? %>
<% if current_user %>
<% if current_user.unverified? %>
<div class="icon-poll-answer unverified" title="<%= t("polls.index.unverified") %>">
<span class="show-for-sr"><%= t("polls.index.unverified") %></span>
@@ -17,6 +13,10 @@
<span class="show-for-sr"><%= t("polls.index.already_answer") %></span>
</div>
<% end %>
<% else %>
<div class="icon-poll-answer not-logged-in" title="<%= t("polls.index.not_logged_in") %>">
<span class="show-for-sr"><%= t("polls.index.not_logged_in") %></span>
</div>
<% end %>
<div class="row" data-equalizer data-equalize-on="medium">
<div class="small-12 medium-3 column">

View File

@@ -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