mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-06-09 17:09:23 +00:00
Only active tab user's own profile
This commit is contained in:
parent
a325b385b3
commit
5e3149ad8e
|
@ -11,14 +11,27 @@ defmodule LiveBeatsWeb.Nav do
|
||||||
|> attach_hook(:active_tab, :handle_params, &handle_active_tab_params/3)}
|
|> attach_hook(:active_tab, :handle_params, &handle_active_tab_params/3)}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_active_tab_params(_params, _url, socket) do
|
defp handle_active_tab_params(params, _url, socket) do
|
||||||
active_tab =
|
active_tab =
|
||||||
case {socket.view, socket.assigns.live_action} do
|
case {socket.view, socket.assigns.live_action} do
|
||||||
{ProfileLive, _} -> :profile
|
{ProfileLive, _} ->
|
||||||
{SettingsLive, _} -> :settings
|
if params["profile_username"] == current_user_profile_userame(socket) do
|
||||||
{_, _} -> nil
|
:profile
|
||||||
|
end
|
||||||
|
|
||||||
|
{SettingsLive, _} ->
|
||||||
|
:settings
|
||||||
|
|
||||||
|
{_, _} ->
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
{:cont, assign(socket, active_tab: active_tab)}
|
{:cont, assign(socket, active_tab: active_tab)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp current_user_profile_userame(socket) do
|
||||||
|
if user = socket.assigns.current_user do
|
||||||
|
user.username
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue