mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-21 15:41:00 +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
|
||||
@moduledoc """
|
||||
Send active users updates using a polling interval.
|
||||
"""
|
||||
|
||||
use GenServer
|
||||
@pubsub LiveBeats.PubSub
|
||||
@poll_interval :timer.seconds(30)
|
||||
|
||||
@doc """
|
||||
TODO
|
||||
"""
|
||||
|
||||
def subscribe() do
|
||||
Phoenix.PubSub.subscribe(@pubsub, topic())
|
||||
end
|
||||
|
|
|
@ -107,7 +107,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
|||
|> list_songs()
|
||||
|> assign_presences()
|
||||
|
||||
{:ok, socket, temporary_assigns: [songs: [], presences: []]}
|
||||
{:ok, socket, temporary_assigns: [songs: [], presences: [], active_users: []]}
|
||||
end
|
||||
|
||||
def handle_params(params, _url, socket) do
|
||||
|
|
|
@ -70,7 +70,7 @@ defmodule LiveBeatsWeb.SettingsLive do
|
|||
|
||||
def mount(_parmas, _session, socket) do
|
||||
changeset = Accounts.change_settings(socket.assigns.current_user, %{})
|
||||
{:ok, assign(socket, changeset: changeset)}
|
||||
{:ok, assign(socket, changeset: changeset), temporary_assigns: [active_users: []]}
|
||||
end
|
||||
|
||||
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}>
|
||||
Active Users
|
||||
</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 %>
|
||||
<.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"
|
||||
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="truncate">
|
||||
|
|
Loading…
Reference in a new issue