Page MenuHomePhabricator

[native] Disable `ImagePasteModal` send button after first press
ClosedPublic

Authored by atul on Mar 14 2022, 11:44 AM.
Tags
None
Referenced Files
F3752336: D3424.diff
Fri, Jan 10, 12:26 AM
Unknown Object (File)
Sun, Jan 5, 2:15 PM
Unknown Object (File)
Sun, Jan 5, 2:15 PM
Unknown Object (File)
Sun, Jan 5, 2:15 PM
Unknown Object (File)
Sun, Jan 5, 2:15 PM
Unknown Object (File)
Sun, Jan 5, 2:15 PM
Unknown Object (File)
Sun, Jan 5, 2:14 PM
Unknown Object (File)
Sun, Jan 5, 2:10 PM

Details

Summary

Disable the button after it's pressed for the first time to prevent issue with multiple sends.

Also moved inputState.sendMultimediaMessage(selection, threadInfo); to an IIFE.

Test Plan
  1. Copy image to clipboard
  2. Paste image into TextInput to pull up ImagePasteModal
  3. Try hitting the send button in quick succession
  4. Make sure that the image only gets sent once

Diff Detail

Repository
rCOMM Comm
Branch
landmarch14 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul requested review of this revision.Mar 14 2022, 11:49 AM
native/chat/image-paste-modal.react.js
37

Alternatively, we could have a [imageSent, setImageSent] = React.useState(false);

and then early exit from sendImage if imageSent is true

ashoat requested changes to this revision.Mar 14 2022, 12:40 PM

Talked about this offline, but the async/await changes aren't necessary here

This revision now requires changes to proceed.Mar 14 2022, 12:40 PM

sendButtonEnabled -> sendButtonDisabled to match Button prop name

ashoat added inline comments.
native/chat/image-paste-modal.react.js
44 ↗(On Diff #10361)

Does it make sense to wrap this in a try-catch and to call setSendButtonDisabled(false) if it throws?

This revision is now accepted and ready to land.Mar 14 2022, 9:41 PM
native/chat/image-paste-modal.react.js
44 ↗(On Diff #10361)

Maybe.. but we're currently calling navigation.goBackOnce(); at the start of this callback. We could await the call to sendMultimediaMessage, but that would keep the modal up a lot longer.

My understanding is that if sendMultimediaMessage fails, it'll be like any other failed message and we'll have a "retry" button appear below it in the message list.

We could do all of this in the modal, but I think we'd need to do a bit more than just wrapping in a try-catch and setSendButtonDisabled(false)?

(Going to land as-is, but happy to address feedback/introduce try-catch in a separate diff)

native/chat/image-paste-modal.react.js
44 ↗(On Diff #10361)

Ah yeah I missed navigation.goBackOnce(), this is more complicated than I thought. Let's just leave it as-is for now