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,10 +31,12 @@ defmodule LiveBeats.MediaLibrary do
end
def broadcast_ping(%Accounts.User{} = user, rtt, region) do
broadcast!(
user.active_profile_user_id,
{:ping, %{user: user, rtt: rtt, region: region}}
)
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

View file

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