mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-21 15:41:00 +00:00
Fix bugs
This commit is contained in:
parent
1975f85cfe
commit
d9b63adb85
2 changed files with 16 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue