fix: clarify blocked request conversations
Some checks are pending
Quality / full-local-gates (push) Waiting to run
Some checks are pending
Quality / full-local-gates (push) Waiting to run
This commit is contained in:
parent
3c37895969
commit
437650d5e2
|
|
@ -294,6 +294,7 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do
|
||||||
socket
|
socket
|
||||||
|> maybe_untrack_browser_presence()
|
|> maybe_untrack_browser_presence()
|
||||||
|> assign(:blocked_by_current, true)
|
|> assign(:blocked_by_current, true)
|
||||||
|
|> assign(:interaction_blocked, true)
|
||||||
|> assign(:messages, [])
|
|> assign(:messages, [])
|
||||||
|> assign(:messages_cursor, nil)
|
|> assign(:messages_cursor, nil)
|
||||||
|> assign(:positions, %{})
|
|> assign(:positions, %{})
|
||||||
|
|
@ -316,9 +317,17 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do
|
||||||
def handle_event("unblock-user", _, socket) do
|
def handle_event("unblock-user", _, socket) do
|
||||||
case Trust.unblock(socket.assigns.current_scope, socket.assigns.other_user_id) do
|
case Trust.unblock(socket.assigns.current_scope, socket.assigns.other_user_id) do
|
||||||
{:ok, _result} ->
|
{:ok, _result} ->
|
||||||
|
interaction_blocked =
|
||||||
|
socket.assigns.other_user_id &&
|
||||||
|
Trust.blocked_between?(
|
||||||
|
socket.assigns.current_scope.user.id,
|
||||||
|
socket.assigns.other_user_id
|
||||||
|
)
|
||||||
|
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:blocked_by_current, false)
|
|> assign(:blocked_by_current, false)
|
||||||
|
|> assign(:interaction_blocked, interaction_blocked)
|
||||||
|> put_flash(:info, gettext("User unblocked."))}
|
|> put_flash(:info, gettext("User unblocked."))}
|
||||||
|
|
||||||
{:error, reason} ->
|
{:error, reason} ->
|
||||||
|
|
@ -432,6 +441,10 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do
|
||||||
:blocked_by_current,
|
:blocked_by_current,
|
||||||
other_user_id && Trust.blocked_by?(current_user_id, other_user_id)
|
other_user_id && Trust.blocked_by?(current_user_id, other_user_id)
|
||||||
)
|
)
|
||||||
|
|> assign(
|
||||||
|
:interaction_blocked,
|
||||||
|
other_user_id && Trust.blocked_between?(current_user_id, other_user_id)
|
||||||
|
)
|
||||||
|> assign(:messages, messages_page.entries)
|
|> assign(:messages, messages_page.entries)
|
||||||
|> assign(:messages_cursor, messages_page.next_cursor)
|
|> assign(:messages_cursor, messages_page.next_cursor)
|
||||||
|> assign(:message_window_limit, max(length(messages_page.entries), @initial_message_window))
|
|> assign(:message_window_limit, max(length(messages_page.entries), @initial_message_window))
|
||||||
|
|
@ -772,7 +785,16 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do
|
||||||
>
|
>
|
||||||
{gettext("Load earlier messages")}
|
{gettext("Load earlier messages")}
|
||||||
</button>
|
</button>
|
||||||
<p :if={@messages == []} class="py-6 text-center text-sm text-base-content/50">
|
<p
|
||||||
|
:if={@interaction_blocked}
|
||||||
|
class="py-6 text-center text-sm font-medium text-error"
|
||||||
|
>
|
||||||
|
{gettext("This interaction is blocked.")}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
:if={@messages == [] && !@interaction_blocked}
|
||||||
|
class="py-6 text-center text-sm text-base-content/50"
|
||||||
|
>
|
||||||
{gettext("No messages yet.")}
|
{gettext("No messages yet.")}
|
||||||
</p>
|
</p>
|
||||||
<div
|
<div
|
||||||
|
|
@ -796,6 +818,7 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<.form
|
<.form
|
||||||
|
:if={!@interaction_blocked}
|
||||||
id="message-form"
|
id="message-form"
|
||||||
for={@message_form}
|
for={@message_form}
|
||||||
phx-submit="send-message"
|
phx-submit="send-message"
|
||||||
|
|
|
||||||
|
|
@ -515,6 +515,31 @@ defmodule WhoNeedHelpWeb.MutualAidLiveTest do
|
||||||
stop_live_view(helper_view)
|
stop_live_view(helper_view)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "request chat clearly disables interaction when the other participant blocks the user", %{
|
||||||
|
conn: requester_conn,
|
||||||
|
scope: requester_scope
|
||||||
|
} do
|
||||||
|
category = Catalog.seed_defaults()
|
||||||
|
helper = user_fixture(display_name: "Blocking helper")
|
||||||
|
|
||||||
|
{:ok, request} = Help.create_request(requester_scope, request_attrs(category))
|
||||||
|
{:ok, assignment} = Help.accept_request(user_scope_fixture(helper), request.id)
|
||||||
|
|
||||||
|
{:ok, _message} =
|
||||||
|
Messaging.send_message(user_scope_fixture(helper), assignment, %{
|
||||||
|
"body" => "This message is hidden after blocking."
|
||||||
|
})
|
||||||
|
|
||||||
|
{:ok, _block} = Trust.block(user_scope_fixture(helper), requester_scope.user.id)
|
||||||
|
|
||||||
|
{:ok, view, html} = live(requester_conn, ~p"/requests/#{request.id}")
|
||||||
|
|
||||||
|
assert html =~ "This interaction is blocked."
|
||||||
|
refute html =~ "No messages yet."
|
||||||
|
refute html =~ "This message is hidden after blocking."
|
||||||
|
refute has_element?(view, "#message-form")
|
||||||
|
end
|
||||||
|
|
||||||
test "terminal request updates stop Android foreground tracking", _context do
|
test "terminal request updates stop Android foreground tracking", _context do
|
||||||
category = Catalog.seed_defaults()
|
category = Catalog.seed_defaults()
|
||||||
requester = user_fixture(display_name: "Tracking requester")
|
requester = user_fixture(display_name: "Tracking requester")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user