improve table route navigation
This commit is contained in:
@ -11,8 +11,8 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
alias Phoenix.LiveView.Socket
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket),
|
||||
do: {:ok, socket |> assign(show_used: false, view_table: false)}
|
||||
def mount(_params, _session, %{assigns: %{live_action: live_action}} = socket),
|
||||
do: {:ok, socket |> assign(show_used: false, view_table: live_action == :table)}
|
||||
|
||||
@impl true
|
||||
def handle_params(
|
||||
@ -21,7 +21,9 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
%{assigns: %{current_user: current_user, live_action: live_action}} = socket
|
||||
) do
|
||||
socket =
|
||||
socket |> assign(view_table: live_action == :table) |> render_container(id, current_user)
|
||||
socket
|
||||
|> assign(view_table: live_action == :table)
|
||||
|> render_container(id, current_user)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
@ -102,7 +104,7 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
do: Routes.container_show_path(Endpoint, :show, container),
|
||||
else: Routes.container_show_path(Endpoint, :table, container)
|
||||
|
||||
{:noreply, socket |> assign(view_table: !view_table) |> push_patch(to: new_path)}
|
||||
{:noreply, socket |> push_patch(to: new_path)}
|
||||
end
|
||||
|
||||
@spec render_container(Socket.t(), Container.id(), User.t()) :: Socket.t()
|
||||
|
Reference in New Issue
Block a user