defmodule LiveBeatsWeb.Presence do @moduledoc """ Provides presence tracking to channels and processes. See the [`Phoenix.Presence`](http://hexdocs.pm/phoenix/Phoenix.Presence.html) docs for more details. """ use Phoenix.Presence, otp_app: :live_beats, pubsub_server: LiveBeats.PubSub import Phoenix.LiveView.Helpers import LiveBeatsWeb.LiveHelpers alias LiveBeats.{Accounts, MediaLibrary} def subscribe(%MediaLibrary.Profile{} = profile) do LiveBeats.PresenceClient.subscribe(profile) end def fetch(_topic, presences) do users = presences |> Map.keys() |> Accounts.get_users_map() |> Enum.into(%{}) for {key, %{metas: metas}} <- presences, into: %{} do {key, %{metas: metas, user: users[String.to_integer(key)]}} end end def listening_now(assigns) do ~H"""

Listening now

""" end end