You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my UC uploading a file is just one of the available media sources, others being selecting a giphy or a media url from a proprietary library.
Now, let's consider the following scenario:
The user tries to upload a file
An upload error is returned and presented
The user selects a media from another library and the selected image/video is shown in place of the previous error
The user cancels the selected media
The upload error from step 2 is shown again for nothing has changed there
I've tried circumventing this by "resetting" the allowed uploads by invoking disallow_upload/2 and then calling the allow_upload/3 in the step 3 but the disallow_upload/2 raises the following exception:
[error] GenServer #PID<0.1255.0> terminating
** (RuntimeError) unable to disallow_upload for an upload with active entries
(phoenix_live_view 0.20.17) lib/phoenix_live_view/upload.ex:65: Phoenix.LiveView.Upload.disallow_upload/2
Expected behavior
I'm aware I could "patch" the above by introducing a flag (assign) in the step no. 3 upon which I will no longer display the upload errors for as long as the flag is there, but wouldn't it be nice to be able to actually reset the uploads instead of doing the workaround?
eg.
disallow_upload( socket, :my_media, force: true)
The text was updated successfully, but these errors were encountered:
Actually, the problem cannot be solved that easily because if I use an assigned flag to ignore the last upload error I also need to reset the flag at some point and it's not obvious when, for the user may as well drag and drop a media to upload it and then I would need to do a flag reset on a subsequent detection of dragover in JS as well as on a click opening the browser's file explorer, all in order to avoid ignoring a new upload error.
Force-resetting the upload(s) would be a far better way of dealing with this issue.
Another reason why the option to force-reset with disallow_upload/2 would be useful is to reset the file types (extensions). In my UC there's a need to do it dynamically because the permitted file type list depends on certain settings the user is permitted to change on the go (within the same LiveComponent)
Environment
Actual behavior
In my UC uploading a file is just one of the available media sources, others being selecting a giphy or a media url from a proprietary library.
Now, let's consider the following scenario:
I've tried circumventing this by "resetting" the allowed uploads by invoking
disallow_upload/2
and then calling theallow_upload/3
in the step 3 but thedisallow_upload/2
raises the following exception:Expected behavior
I'm aware I could "patch" the above by introducing a flag (assign) in the step no. 3 upon which I will no longer display the upload errors for as long as the flag is there, but wouldn't it be nice to be able to actually reset the uploads instead of doing the workaround?
eg.
The text was updated successfully, but these errors were encountered: