mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-14 20:21:01 +00:00
Assign active_tab in handle_params to handle live patches
This commit is contained in:
parent
62e00dc447
commit
7f9b7c5f9a
1 changed files with 8 additions and 5 deletions
|
@ -5,6 +5,13 @@ defmodule LiveBeatsWeb.Nav do
|
|||
alias LiveBeatsWeb.{ProfileLive, SettingsLive}
|
||||
|
||||
def on_mount(:default, _params, _session, socket) do
|
||||
{:cont,
|
||||
socket
|
||||
|> assign(active_users: MediaLibrary.list_active_profiles(limit: 20))
|
||||
|> attach_hook(:active_tab, :handle_params, &handle_active_tab_params/3)}
|
||||
end
|
||||
|
||||
defp handle_active_tab_params(_params, _url, socket) do
|
||||
active_tab =
|
||||
case {socket.view, socket.assigns.live_action} do
|
||||
{ProfileLive, _} -> :profile
|
||||
|
@ -12,10 +19,6 @@ defmodule LiveBeatsWeb.Nav do
|
|||
{_, _} -> nil
|
||||
end
|
||||
|
||||
{:cont,
|
||||
assign(socket,
|
||||
active_users: MediaLibrary.list_active_profiles(limit: 20),
|
||||
active_tab: active_tab
|
||||
)}
|
||||
{:cont, assign(socket, active_tab: active_tab)}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue