From e76742a27bd716dfe2f5e47601109050070331a7 Mon Sep 17 00:00:00 2001 From: Berenice Medel Date: Wed, 2 Feb 2022 14:48:11 -0600 Subject: [PATCH] untrack user from presence when a new profile is chosen --- lib/live_beats_web/live/player_live.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/live_beats_web/live/player_live.ex b/lib/live_beats_web/live/player_live.ex index 9226c56..26bc162 100644 --- a/lib/live_beats_web/live/player_live.ex +++ b/lib/live_beats_web/live/player_live.ex @@ -155,6 +155,10 @@ defmodule LiveBeatsWeb.PlayerLive do if profile && connected?(socket) do current_user = Accounts.update_active_profile(current_user, profile.user_id) + #untrack last profile the user was listening + if socket.assigns.profile do + LiveBeats.PresenceClient.untrack(socket.assigns.profile, current_user.id) + end LiveBeats.PresenceClient.track(profile, current_user.id) send(self(), :play_current)