Skip to content
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

compose: Don't send immediately on adding image #5474

Merged
merged 5 commits into from
Jan 12, 2023

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Aug 23, 2022

Thanks @AkashDhiman for your PR #5125 and your prep work for this in #4590; those were quite helpful and informative. 🙂

Marked as a draft/blocked for a reason I'll explain, but that reason doesn't affect the first three commits—

ComposeMenu [nfc]: Use our own new type definition for attachments
ComposeMenu [nfc]: Fix name of insertAttachment prop to be plural
ComposeMenu [nfc]: Convert to a function component

—and indeed those three would be good to land as prep for removing the blocker.

The blocker is that we have basically the behavior of #5291, except with the insertion of image links instead of Jitsi links. On iOS, you take or select a photo to upload, and sometimes the message text input is unchanged when you expect it to get an inserted [Uploading …]() link.

Fixes: #2366
Fixes: #4540
Replaces: #5125

@chrisbobbe chrisbobbe added P1 high-priority blocked on other work To come back to after another related PR, or some other task. labels Aug 23, 2022
@chrisbobbe chrisbobbe assigned chrisbobbe and unassigned chrisbobbe Aug 23, 2022
@chrisbobbe chrisbobbe marked this pull request as draft August 25, 2022 17:49
@gnprice
Copy link
Member

gnprice commented Aug 25, 2022

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisbobbe! This code all looks good except the small points below.

That leaves as the interesting questions:

class ComposeMenuInner extends PureComponent<Props> {
static contextType = TranslationContext;
context: GetText;
export default function ComposeMenuInner(props: Props): Node {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: There's no longer a distinct "inner" vs "outer" component here, right? So this function should be called just ComposeMenu.

(Another angle on the same thing: it's the default export, so should have the same name as the file.)

Comment on lines 160 to 180
msg = _('Failed to attach your file.');
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets a local and then returns -- so the assignment has no effect, as nothing else can see it.

Perhaps just put the showErrorAlert call here? It's pretty concise, not much more complex than the variable assignment.

@chrisbobbe
Copy link
Contributor Author

Thanks for the review! Revision pushed.

@chrisbobbe chrisbobbe removed the blocked on other work To come back to after another related PR, or some other task. label Jan 11, 2023
@chrisbobbe chrisbobbe marked this pull request as ready for review January 11, 2023 19:57
@chrisbobbe
Copy link
Contributor Author

@gnprice, I've just rebased this atop #5635, so it's ready for another code review. I'm working on spinning up the simulator to make a screen recording now. 🙂

@chrisbobbe
Copy link
Contributor Author

Just pushed a revision fixing a rebase error in the new type Attachment's definition (r-n-document-picker changed an optional string property to required with string | null).

Here's a video of the feature working on my iPhone:

RPReplay_Final1673470049.mp4

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revision!

Code all looks good; small comment below.

On the UI this gets us on Android: I'm still not a fan of that file-picker-style UI when the user asks to upload a photo. The first part of this branch, the "don't send immediately", is a major functionality improvement. But "select multiple images at once" doesn't seem as necessary:

  • Lots of messaging apps don't even let you send multiple images in one message.
  • If you do want to send multiple images, then given the "don't send immediately" part of this branch, all you have to do is go through the selection multiple times.

So I'm not sure that that part is a good trade for the added inconvenience of the file-picker flow each time you want to send one photo.

Therefore I think what I want to do here is:

});
return;
}

dispatch(uploadFile(destinationNarrow, uri, chooseUploadImageFilename(uri, fileName)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was the only call site of that uploadFile function — so let's cut that out too.

chrisbobbe and others added 5 commits January 12, 2023 12:03
This function is designed to insert multiple attachments.
Soon, we'd like to also use the `insertAttachments` prop not just
for react-native-document-picker payloads, but also for
react-native-image-picker payloads. Better to define our own type
that's meant to accommodate both kinds, rather than, e.g., using
react-native-document-picker's type and fudging image-picker
payloads to flow through that type.

While we're at it, trim down the type to just what
`insertAttachments` currently uses: the url [1] and a nullable name
for the file. The `type` property in particular smells like
something that might not be easy to make uniform across
document-picker and image-picker payloads; there's no comment
linking to a spec that says what the possible values of `type` mean,
for example.

[1] renamed from "uri"; see style guide
For why this closes zulip#2366, see Greg's explanation:
  zulip#5474 (review)

Fixes: zulip#4540
Fixes: zulip#2366
Co-authored-by: Akash Dhiman <[email protected]>
…ehavior

A skim through Sentry events matching the old error message suggests
that we haven't yet had reports of firstAsset being present but with
nullish `url` or `fileName`. But the types say they can be
undefined, and we'll want to know if that's ever the case.
@chrisbobbe
Copy link
Contributor Author

Thanks for the review! Revision pushed.

@gnprice gnprice changed the title compose: Allow multiple image selection; don't send immediately compose: Don't send immediately on adding image Jan 12, 2023
@gnprice gnprice merged commit d815680 into zulip:main Jan 12, 2023
@gnprice
Copy link
Member

gnprice commented Jan 12, 2023

Thanks! Looks good; merging.

@chrisbobbe chrisbobbe deleted the pr-send-multiple-images branch January 12, 2023 22:11
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jan 12, 2023
We recently completed the feature of not immediately sending
messages with image uploads, in zulip#5474. With that, it became possible
to send a message with multiple uploaded images in it. But you had
to go through the image-selection flow once for each of your chosen
images; see discussion:
  zulip#5474 (review)

This gives a smoother experience by letting you choose multiple
images in one image-selection session.

Related: zulip#2366
Co-authored-by: Akash Dhiman <[email protected]>
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jan 12, 2023
We recently completed the feature of not immediately sending
messages with image uploads, in zulip#5474. With that, it became possible
to send a message with multiple uploaded images in it. But you had
to go through the image-selection flow once for each of your chosen
images; see discussion:
  zulip#5474 (review)

This gives a smoother experience by letting you choose multiple
images in one image-selection session.

Related: zulip#2366
Co-authored-by: Akash Dhiman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't immediately send attachment on upload [Android] Multiple file selection when uploading pictures.
2 participants