mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-25 09:20:59 +00:00
set active_users as temporary assigns
This commit is contained in:
parent
b8608bc77d
commit
6c3eacf66f
4 changed files with 14 additions and 7 deletions
|
@ -1,12 +1,12 @@
|
||||||
defmodule LiveBeats.UserTracker do
|
defmodule LiveBeats.UserTracker do
|
||||||
|
@moduledoc """
|
||||||
|
Send active users updates using a polling interval.
|
||||||
|
"""
|
||||||
|
|
||||||
use GenServer
|
use GenServer
|
||||||
@pubsub LiveBeats.PubSub
|
@pubsub LiveBeats.PubSub
|
||||||
@poll_interval :timer.seconds(30)
|
@poll_interval :timer.seconds(30)
|
||||||
|
|
||||||
@doc """
|
|
||||||
TODO
|
|
||||||
"""
|
|
||||||
|
|
||||||
def subscribe() do
|
def subscribe() do
|
||||||
Phoenix.PubSub.subscribe(@pubsub, topic())
|
Phoenix.PubSub.subscribe(@pubsub, topic())
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,7 +107,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
|> list_songs()
|
|> list_songs()
|
||||||
|> assign_presences()
|
|> assign_presences()
|
||||||
|
|
||||||
{:ok, socket, temporary_assigns: [songs: [], presences: []]}
|
{:ok, socket, temporary_assigns: [songs: [], presences: [], active_users: []]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_params(params, _url, socket) do
|
def handle_params(params, _url, socket) do
|
||||||
|
|
|
@ -70,7 +70,7 @@ defmodule LiveBeatsWeb.SettingsLive do
|
||||||
|
|
||||||
def mount(_parmas, _session, socket) do
|
def mount(_parmas, _session, socket) do
|
||||||
changeset = Accounts.change_settings(socket.assigns.current_user, %{})
|
changeset = Accounts.change_settings(socket.assigns.current_user, %{})
|
||||||
{:ok, assign(socket, changeset: changeset)}
|
{:ok, assign(socket, changeset: changeset), temporary_assigns: [active_users: []]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("validate", %{"user" => params}, socket) do
|
def handle_event("validate", %{"user" => params}, socket) do
|
||||||
|
|
|
@ -13,10 +13,17 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
<h3 class="px-3 text-xs font-semibold text-gray-500 uppercase tracking-wider" id={@id}>
|
<h3 class="px-3 text-xs font-semibold text-gray-500 uppercase tracking-wider" id={@id}>
|
||||||
Active Users
|
Active Users
|
||||||
</h3>
|
</h3>
|
||||||
<div class="mt-1 space-y-1" role="group" aria-labelledby={@id}>
|
<div
|
||||||
|
class="mt-1 space-y-1"
|
||||||
|
role="group"
|
||||||
|
aria-labelledby={@id}
|
||||||
|
id="listening-now"
|
||||||
|
phx-update="prepend"
|
||||||
|
>
|
||||||
<%= for user <- @users do %>
|
<%= for user <- @users do %>
|
||||||
<.link navigate={profile_path(user)}
|
<.link navigate={profile_path(user)}
|
||||||
class="group flex items-center px-3 py-2 text-base leading-5 font-medium text-gray-600 rounded-md hover:text-gray-900 hover:bg-gray-50"
|
class="group flex items-center px-3 py-2 text-base leading-5 font-medium text-gray-600 rounded-md hover:text-gray-900 hover:bg-gray-50"
|
||||||
|
id={"active-user#{user.id}"}
|
||||||
>
|
>
|
||||||
<span class="w-2.5 h-2.5 mr-4 bg-indigo-500 rounded-full" aria-hidden="true"></span>
|
<span class="w-2.5 h-2.5 mr-4 bg-indigo-500 rounded-full" aria-hidden="true"></span>
|
||||||
<span class="truncate">
|
<span class="truncate">
|
||||||
|
|
Loading…
Reference in a new issue