missing link to restore conversation (fixes philomena-dev/philomena#42)

This commit is contained in:
byte[] 2020-10-23 00:15:29 -04:00
parent 4cf02da8e6
commit c30c8e3136
2 changed files with 13 additions and 1 deletions

View file

@ -16,7 +16,10 @@ h1 = @conversation.title
=> @messages.total_entries
= pluralize("message", "messages", @messages.total_entries)
= pagination
= link "Remove conversation", to: Routes.conversation_hide_path(@conn, :create, @conversation), data: [method: "post", confirm: "Are you really, really sure?"]
= if hidden_by?(@current_user, @conversation) do
= link "Restore conversation", to: Routes.conversation_hide_path(@conn, :delete, @conversation), data: [method: "delete"]
- else
= link "Remove conversation", to: Routes.conversation_hide_path(@conn, :create, @conversation), data: [method: "post", confirm: "Are you really, really sure?"]
= link "Report conversation", to: Routes.conversation_report_path(@conn, :new, @conversation)
= link "Mark as unread", to: Routes.conversation_read_path(@conn, :delete, @conversation), data: [method: "delete"]

View file

@ -16,6 +16,15 @@ defmodule PhilomenaWeb.ConversationView do
def read_by?(_user, _conversation),
do: false
def hidden_by?(%{id: user_id}, %{to_id: user_id} = conversation),
do: conversation.to_hidden
def hidden_by?(%{id: user_id}, %{from_id: user_id} = conversation),
do: conversation.from_hidden
def hidden_by?(_user, _conversation),
do: false
def conversation_class(user, conversation) do
case read_by?(user, conversation) do
false -> "warning"