-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Improve Image Upload Workflow #2887
Conversation
Awesome! Looking forward to getting this in. This is a fairly complex feature to build -- and that interaction in those screencaps looks pretty reasonable and this code and the commits look quite clean, so this is an excellent start.
Sounds like the library isn't properly declaring one of its dependencies, perhaps. If you try an Android build, do you reproduce the error?
|
Also, sorry this code is duplicated :-/ . That's a hack we did in #2595 , to work around two different React Native bugs at the same time (one that affected Android, one iOS, and triggered in opposite circumstances.) With #2886 we'll merge them into one file again soon. The new one will be based mainly on the current |
@gnprice Thanks for the feedback! And for making me aware of those two PRs. I'll be working on updating this PR after tomorrow so will pull in master before I do ( in trying to avoid too many future conflicts ). Looking forward to getting this in too! |
6f5e98d
to
dc1d7e1
Compare
7741d04
to
0e31273
Compare
Hey @gnprice -- I've updated this PR with tests, lint changes and all the feedback you had. |
Thanks @armaanahluwalia ! Re-reviewing this now; apologies for the delay. First, a few comments from playing with this version of the app. These are all from an emulated Pixel 2 XL running Android 8.1.0 Oreo.
Do you have an Android development environment set up? It looks like this is going to be a change where you'll need to play with it on both platforms in order to get to something really good. Setting one up is fortunately very straightforward -- there are a fair number of steps involved, but there are instructions and they should work reliably. See our guide and the upstream instructions it links to. Separately, some comments from reading the code.
|
7a51356
to
56c8830
Compare
@armaanahluwalia Is this meant to be ready for a re-review? It looks like you've pushed a new version of the branch. The way GitHub works, it doesn't send notifications when you do that, so a reviewer won't necessarily ever notice -- so the recommended workflow is that when responding to a review, you always make a comment when the new version is ready. (This one, I noticed because the PR is one I'm eager to get merged 😄 , and have on our priority list at https://github.com/zulip/zulip-mobile/projects/7 .) |
56c8830
to
5894120
Compare
@gnprice I'm sorry I wanted to be sure it passed the tests before I notified you. I addressed all the changes you requested except for the "slowness" while clicking the plus icon. That one I'm having a hard time figuring out but will try to debug further. The rest is ready to be reviewed. Edit: The other thing to note is that this depends on compileSdkVersion 26 so it would follow the RN 56 upgrade i guess. |
Great! Nothing to apologize for 😄 Happy to re-review the other aspects, with your warning that that slowness issue is still there. I'll take a look now. On the slowness issue: have you been able to reproduce it and you're still debugging, or have you not been able to reproduce? |
(cont'd) |
On the
OK, I'll leave it there for now. Thanks again -- looking forward to the next version! |
@gnprice thanks for those comments I’ll follow up with those changes. I did manage to get an emulator running with the same configuration as you ( barely with my machine RAM ) and also tested on a physical android device. Regarding the screen when you click the picture icon — |
OK, good to hear. Were you able to reproduce the slowness issue and you're still debugging, or have you not been able to reproduce it? If you have a physical Android device and you're at all short of RAM on your laptop/desktop, I recommend using the device. Things are more fun as well as more efficient when your computers respond quickly 😉 (When using my laptop, I prefer to do development on my physical device in order to save screen space, as well as RAM and also CPU and GPU load. The emulator is convenient on my desktop because I have a large monitor, a good GPU, and lots of RAM.)
Hrm. That behavior would be suboptimal but OK. But that's not what I'm seeing (on Android 8.1 in my simulated Pixel 2 XL) -- I hit the picture icon, get that screen, go through the flow to choose an image, send a message with it... and when I then hit the picture icon again while composing another message, I get the same "Recent -> No items" screen again. In what environment are you seeing the behavior you're seeing? |
5894120
to
80dc06d
Compare
@gnprice This PR is ready for review. I addressed all the points in your feedback ( I hope ). As for the following 2 points:
Side Note: |
Thanks @armaanahluwalia ! This is very helpful.
put the new thing on the same line instead of a different one.
I have to head off shortly, but a few thoughts on the later commits:
as
Why do we Also, is that
|
80dc06d
to
7f4fa5b
Compare
@gnprice I've updated this PR with the changes you requested. Here are some notes on the update in response to some of your comments and queries: Dependency Change: I added some more detail to the commit and re-did the commit from scratch just to make sure I wasn't doing anything unnecessary. The one caveat is that I can't actually test this properly since the "Archive" action is disabled for me on XCode so I can't be sure how this will build for production code. I think this is because I'm not technically on the "team" under apple developers or whatever. Perhaps you could verify this by doing the archive step? Draft Images: I renamed the property in reducer to being one key as you suggested. I do think this makes sense. I kept them as separate actions because I feel thats kind of a best practice which I completely agree with. Makes for better logging, signatures and general readability. This way we don't need to click into a log object each time we want to see the details of an action. Try Catches: I refactored a bunch of code and the remaining try-catches in there actually do have specific functions. One to verify a corrupt image is not being selected. Another to verify a file is uploaded correctly etc. Slowness of the Plus Icon: This one I'm puzzled by. I was actually seeing this while developing for a while. I switched out to the tip of master and it appeared there as well so its not a bug specific to this PR. The problem is I can't reliably reproduce this on either branch now. I do know that between the time the plus icon is clicked and the menu actually animates there are no actions fired. This has to do with some kind of slowness elsewhere in the code that shares the same thread as the animation. |
This commit replaces react-native-image-picker in favor of react-native-image-crop-picker. It solves a few key issues like being able to - 1) Select multiple images 2) Being able to downsample image quality. See issue zulip#2749 3) Being able to scale down images. 4) Being faster at processing images. The removal of react-native-image-picker was done by: 1) Removing dependency from yarn 2) Running react-native unlink react-native-image-picker 3) Checking the initial commit and removing any code that may not be covered by unlink. For reference the initial commit that introduced changes was 515436a. The addition of react-native-image-crop-picker is done by following the installation instructions at https://github.com/ivpusic/react-native-image-crop-picker/blob/07d321e3bc279b0ad218817245264cda6a7c77cb/README.md This involved: 1) Adding the dependency via yarn 2) Running react-native link react-native-image-crop-picker 3) Adding the frameworks under embedded binaries as described by this comment ivpusic/react-native-image-crop-picker#61 (comment) and also under the "Manual" section of the PostInstall steps. Note: We are ignoring a few of the PostInstall steps described in the Readme namely: 1) Changing the deployment target to 8.0 - We already have a higher target set. 2) The steps described in "To localizate the camera / gallery text buttons" - I dont believe this is required and the instructions seem vague. 3) Adding "useSupportLibrary" as described in a previous commit - This is required for cropping images and we don't have that feature enabled currently. When we enable that feature we will want to add this as well. Note: We want to test this commit is working by archiving the project and uploading to TestFlight.
Update the implementation of image uploading in ComposeMenu.js We adopt react-native-image-crop-picker in favor of the old library (react-native-image-picker). This gives us the additional ability to downsample and downscale images before uploading them and also allows selecting multiple images in the same selection ( iOS only for now ). These changes will be implemented in a following commit. Currently, there is a bug in the image picker which results in the max width and height to only be applied on android. This is still an improvement over the previous library but will need to be kept in mind so when that bug is fixed we can upgrade. See ivpusic/react-native-image-crop-picker#604
This commit adds a new category of reducers, selectors and actions along with their associated tests and types for saving image drafts. This component will be used to show previews of images selected from the image picker and will be utilized in a following commit.
This commit makes the necessary changes to ComposeMenu and ComposeBox in order to select and upload images per message while composing while showing a thumbnail preview. It also allows you to delete a selected image before sending the message and choose another one. The code in this commit is written to handle multiple images but the max limit is currently set to 1. Can enable more in the future. It also allows you to select a topic for an image.
dfcd4a8
to
4e57737
Compare
@gnprice I've updated this branch with code changes. I believe merging in #3118 first makes sense since after thats done I can incorporate that new withPreview action into the code. Either ways take a look. Couple of things I haven't been able to tackle:
Let me know if you see anything else. |
Build is failing due to a possibly unrelated cause: |
FYI @gnprice I believe my other changes for uploading images with a loading spinner, waiting till its uploaded and then sending should also be incorporated ( I left them out at your request here because you said you'd like to merge e stripped down version ). With all the issues i've been facing for image uploads recently, I really believe that flow is a much more fool proof way to go. It also kind of trains the user to wait for images to upload before -- say for example, closing the app, going to another stream, taking other actions. These are all flows that are from what I can tell untested and a cause for bugs in the code you have currently. I'm not saying this is a dealbreaker issue but thats my view on things. Maybe I'm also just a little frustrated at how many issues I'm facing with uploading pictures in the app right now. Let me know thoughts. |
I'm sure @borisyankov has thoughts on this since you worked on #3118 |
I also think we might be underestimating how many people are actually on imperfect networks. The code I had handled a bunch of cases around network failure which, barring some other future PRs working on retries, network failure, queueing etc. has not really been taken into account. On a side note: I'd really love to get this merged in for the upcoming release whenever that is. |
@gnprice Just wanted to ping and see if there's any plan to integrate this? If yes, I'll fix up conflicts. |
@armaanahluwalia Just wanted to reassure you that we consider the problem this PR addresses to be important and that we want to merge this work soon :) I think we got to the position where a lot of work is tied together and lives and dies together. |
Some comments:
That is certainly needed!
That I think both me and Greg think is not necessarily important.
That is good. I am not sure we initially were decided on how important that is, but with future improvements of the retry logic of image uploads (I could work on this soon) this will be even more viable. I know I do send multiple images sometimes and appreciate it being made easier.
That is important, but maybe our last commits addressed that at least partially (it was a bug that the wrong topic got set).
Very important, though this can easily be added even with the current image picker. But good to have it done! |
Just to clarify: most of my comments include my thoughts and what I remember Greg's opinions were when we did review the work together last. I had some time to think after that on the way we approach this. I think it is very valuable to upload the images in two steps:
We miss step 2 right now and your work is addressing that. We can implement this without any drafts, as mixing images and text is not going to work well anyway. |
@borisyankov Thanks for those comments. It certainly is reassuring to hear the majority of this work won't go fruitless. I'm just a little confused as to what next steps should be now. I also don't fully understand why you would want to treat images as a special case. Since we're creating drafts out of text -- I'm not exactly sure why we wouldn't do the same with image uploads. I feel like a user would expect his selections to be saved just like they are for text. I also disagree that sending images and text together is not important. I think its that kind of functionality that really sets a decent app apart from a really good app. I do understand though if thats something you want to implement as a v2. To be clear, I think having drafts for images makes a lot of sense, both from a user experience perspective as well as since most ( if not all ) of the work for it has already been done : ) Would love to get some direction on next steps. |
Images are treated as a special case in your code. In fact, it is not necessary to treat them as such, if you include the link in the message body as markdown. This will completely skip the need for a separate reducer. Also, I think this is not adding too much control or a difference between what would happen if you send the images and the text separately as you can't position the messages. |
@borisyankov I'm not sure what you mean. Having images saved as drafts has the following advantages -
|
I wanted to make clear that different parts of this PR are at different stages of being ready and since this is implementing several related but different features it will help if we merge them independently. While I do not have comments or objections about many of the parts, I do about others, and this drags the whole PR (I am sure Greg has similar or different ones, this is a big PR) For example, we could use the
And do not need to create another reducer separately. After testing the current branch:
I didn't go too deep in how the code would handle retries of draft images that did not send etc. but at this point we are stretching the feature set that is reasonable to merge at once. |
@borisyankov Yep the code was simplified on request from greg. I'd like to get @gnprice comments on what to do to move this forward. I feel like its been sitting around long enough : ) |
Thanks @armaanahluwalia for all your work on this, and for the latest revisions! I think my main high-level piece of feedback on this PR is: you need to set up for yourself a working Android development environment, so you can try the UI out on Android. This is a very UX-oriented PR, and it's one that (inevitably) has a lot of platform-specific aspects. It's not possible to adequately develop it without trying it on both platforms. I remember this was a major source of problems in the early history of this PR. Trying the branch out just now in Android O on an emulated Pixel 2, it does basically work (:tada:), but there are still some UX bugs that jump out at me. I could describe them in detail, which is the tack we took early in this PR... but really it is less work in total -- and I think you will find it a much shorter and less frustrating iteration cycle! -- if you see them firsthand by playing with it yourself. In fact, I see now that I made this point back in September:
Having a working Android development environment will be helpful for you again and again beyond this PR too. You mention that the emulator isn't working for you:
This sounds like a Zulip-independent problem, so there should be useful advice for it on the Web. The first thing I'd suggest: wipe that emulated device (that "AVD"), and make a fresh one. Maybe make a fresh one from a different system image -- a different OS version, for example. If you're continuing to have trouble and aren't finding useful advice on the Web, let's debug in chat. |
Some more specific thoughts:
Just to be clear: I described above my experience on my personal device, running Android 9. That is as new as it gets. 😛 The flow was not a good one. But as I said here, I think it's not clearly worse than the existing flow, so I'll be OK with merging even with that issue.
This is what #3118 also does, right? Or is there a subtler distinction you have in mind? I agree that that functionality will be important. I also agree generally with @borisyankov 's replies. I'm not sure about the question of whether we can avoid the new concept of "draft images"; that is interesting and I'll want to think about it more. One way of looking at what "draft images" are doing would be: they're tracking image uploads that we're currently doing, or have attempted and need to retry, etc. I think that's the piece that isn't covered in this example:
From that perspective, in order to do nice retrying of image uploads, and also to show in the UI when an image is uploaded that you're planning to include in a draft message, we need some kind of tracking like this. But perhaps "draft" isn't the right framing for it. In some ways they're more like our "outbox" messages than our draft messages. @borisyankov , what do you think of that explanation? |
Thanks everyone for your work writing and reviewing this PR! I'm closing it as mostly superseded by #5474 and #5638, which fixed these issues:
I see that this PR was also meant to fix these issues: And those issues are still open. But so many merge conflicts have gathered that I think it would be more productive to address those issues with a new PR freshly written from the current I encourage @armaanahluwalia and anyone else interested in this PR to try out the new UI (first released in the v27.198 beta on 2023-01-12) and see what you think. 🙂 |
This PR does a few different things in relation to improving the user experience for uploading image attachments along with messages:
This is done by the following changes -
To Do:
Screenshots:
Adding Single Image
Adding Multiple Images - Delete one, add one, hit max limit
Network Failure during upload. Recovery from failure.