This commit is contained in:
Chris McCord 2022-01-31 22:12:32 -05:00
parent 1975f85cfe
commit d9b63adb85
2 changed files with 16 additions and 13 deletions

View file

@ -31,11 +31,13 @@ defmodule LiveBeats.MediaLibrary do
end
def broadcast_ping(%Accounts.User{} = user, rtt, region) do
if user.active_profile_user_id do
broadcast!(
user.active_profile_user_id,
{:ping, %{user: user, rtt: rtt, region: region}}
)
end
end
def unsubscribe_to_profile(%Profile{} = profile) do
Phoenix.PubSub.unsubscribe(@pubsub, topic(profile.user_id))

View file

@ -102,13 +102,14 @@ defmodule LiveBeatsWeb.ProfileLive.UploadFormComponent do
end
defp put_new_changeset(socket, entry) do
if get_changeset(socket, entry.ref) do
cond do
get_changeset(socket, entry.ref) ->
socket
else
if Enum.count(socket.assigns.changesets) > @max_songs do
raise RuntimeError, "file upload limited exceeded"
end
Enum.count(socket.assigns.changesets) > @max_songs ->
socket
true ->
attrs = MediaLibrary.parse_file_name(entry.client_name)
changeset = MediaLibrary.change_song(%MediaLibrary.Song{}, attrs)