-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove fetch after upload #1848
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1848 +/- ##
============================================
+ Coverage 66.13% 66.22% +0.09%
Complexity 314 314
============================================
Files 651 651
Lines 10768 10772 +4
============================================
+ Hits 7121 7134 +13
+ Misses 3647 3638 -9
|
Size Change: +9 B (0%) Total Size: 830 kB
ℹ️ View Unchanged
|
The fetch after upload was added for two reasons.
@cvolzke4 you need to take into account this case in this PR, I believe. |
549e054
to
714f10c
Compare
In these changes, the return value from 'await uploadFile(localFile.file)' is used to update the media directly. I tested this by drag/drop of an image into the media pane, and checked that the attributes are consistent with a server reload. When using the 'Upload' button to upload into WP, the media pane is reloaded elsewhere, but it's still reloaded as expected. |
assets/src/edit-story/app/media/useUploadMedia/useUploadMedia.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with the new Map
fix, this PR didnt work for me. The progress bar on the upload remained forever and was never replaced with uploaded version.
714f10c
to
af63983
Compare
How does this PR work when a filter is active?
Currently this just add the image to the top of the list, is that correct? I am not sure how we work around this, unless if does the refetch if a filter or search is set overwise, just adds to the top? |
af63983
to
0c63ac0
Compare
I was too fast to reply. This has been fixed, please try again. |
Also worthing noting that seems like force pushing here to rewrite commits. Please avoid doing this, as making pulling your change hard as I have to delete the branch and fetch it again. |
It's a good question, this may be a case for re-fetching (or re-apply the search in memory, if that's easy to do). Another way to look at it is as a 'feature', so that the user can see what they just uploaded. It may appear to be a glitch if an upload finishes, and then the image (or images) suddenly disappear. When a search is active inside the WP uploader, the image isn't displayed, but image details appear on a pane to the right of the list (the last uploaded image if multiple were dropped). It may not matter very much, as the user can re-enter the search term to re-apply the filter if needed. This sounds like a question for UX, WDYT? |
Thanks for letting me know. I was under the impression that this only affects a pull if another contributor is making changes to the same branch. |
I don't think this is the updated version, try refreshing the browser. |
Changes like this really need a ticket first and a the solution to be discussed before any code is written. If that was the case I would have pointed out the pitfalls and why we had to be the refetch in the first place.
We need to validate that this doesn't break the 5 kinds of upload
|
Thanks Jonny. This change relates to the performance ticket (which I've linked now, I should have done this earlier). I'll raise another ticket Monday to address the specific change. I had started this PR as a way to communicate this in a comment elsewhere, and then finished the implementation since it wasn't very much work and I could receive feedback on the approach, which you have given (thank you). I'll write some new tests once the behavior has been confirmed with Sam. Please bear with me while we find our feet working with github, linking issues, getting feedback etc, as you can understand it's a very different environment to what we are used to. I've just tested the upload types that you mentioned, including upload of multiple files. There's a few other issues that I noticed while testing:
|
fileUploaded, | ||
]) | ||
); | ||
setMedia({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like reshuffling the whole array of media elements is a lot. I think we already have updateMediaElement
. Can we use it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is today, the reducer for updateMediaElement is also O(n) for each media element. But we should be able to refactor it to take more than one media element at a time.
Here is an issue to address this: #2072
...media, | ||
], | ||
}); | ||
updatedMedia = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have instead a targeted method prependMedia
and resolve array logic and stuff on the reducer level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a better way, this is an existing issue that can be addressed in a separate PR. I've raised an issue: #2072
Honestly, there are still a lot of question regarding the UX of the media library about expected behavior. Like What you are scrolled down say 200th item in the media list, does the preview appear at the top of the list? I don't think that we can work with the idea that current UX is correct as most of it was written before any of the current designs were implemented. Until UX is confirmed, is hard to know if this PR is doing that correct behavior. |
@cvolzke4 trying to catch up on this. is this ready to be rereviewed? I'm generally LG with changes, but there's a longish threads with other reviewers... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Remove fetch after upload. Instead, retrieve the updated resource info from the response of the upload api call.
This solves two problems: