live_beats/lib/live_beats_web/live/nav.ex

22 lines
522 B
Elixir
Raw Normal View History

2021-10-29 16:12:23 +00:00
defmodule LiveBeatsWeb.Nav do
import Phoenix.LiveView
2021-11-12 15:10:04 +00:00
alias LiveBeats.MediaLibrary
2021-11-22 14:57:24 +00:00
alias LiveBeatsWeb.{ProfileLive, SettingsLive}
2021-11-12 15:10:04 +00:00
2021-11-22 15:31:30 +00:00
def on_mount(:default, _params, _session, socket) do
2021-11-19 19:50:36 +00:00
active_tab =
2021-11-22 15:31:30 +00:00
case {socket.view, socket.assigns.live_action} do
{ProfileLive, _} -> :profile
2021-11-22 14:57:24 +00:00
{SettingsLive, _} -> :settings
{_, _} -> nil
end
2021-11-19 19:50:36 +00:00
2021-11-22 14:57:24 +00:00
{:cont,
assign(socket,
active_users: MediaLibrary.list_active_profiles(limit: 20),
active_tab: active_tab
)}
2021-10-29 16:12:23 +00:00
end
end