Skip to content

Commit

Permalink
Move logic to MessageThreadHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Sep 19, 2024
1 parent d44f66e commit df54689
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/components/message_threads_table_row_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@
<div class="flex flex-wrap gap-2 text-gray-500 text-xs md:text-base items-center">
<% if @message_thread.sender || @message_thread.recipient %>
<span class="text-left font-normal">
<% if @message_thread.box.communication_to_multiple_subjects? %>
<% if @message_thread.is_outbox && @message_thread.recipient.present? %>
Komu: <%= @message_thread.recipient %>
<% elsif !@message_thread.is_outbox && @message_thread.sender.present? %>
Od: <%= @message_thread.sender %>
<% end %>
<% elsif @message_thread.sender.present? %>
<% if MessageThreadHelper.show_recipient?(@message_thread) %>
Komu: <%= @message_thread.recipient %>
<% elsif MessageThreadHelper.show_sender?(@message_thread) %>
Od: <%= @message_thread.sender %>
<% end %>
</span>
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/message_thread_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module MessageThreadHelper
def self.show_recipient?(message_thread)
message_thread.box.communication_to_multiple_subjects? && message_thread.is_outbox && message_thread.recipient.present?
end

def self.show_sender?(message_thread)
!message_thread.box.communication_to_multiple_subjects? || (!message_thread.is_outbox && message_thread.sender.present?)
end
end

0 comments on commit df54689

Please sign in to comment.