App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment June 29] Update compose box to send photos and text in one message

Open kadiealexander opened this issue 5 years ago • 38 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Expected Result:

  1. When uploading image attachments in Expensify.cash, the existing attachment preview modal should appear. Instead of saying "Upload", it should now say "Send".

This should work the same for all three modes of interaction: - Manually picking an image using the AttachmentPicker, - Drag-and-dropping a photo into the ReportActionCompose, - Pasting a photo into the ReportActionCompose from the platform's native clipboard.

  1. After hitting "Send", any draft text in the composition box should be sent, followed by the attached image below the text.

@mallenexpensify @shawnborton if you have nothing else to add here then feel free to apply the External label so we can get this on Upwork.

Actual Result:

  • Image uploads and text in compose box persists.

Action Performed:

Web/Desktop

  • Type text in compose box
  • Drag/drop image to compose box to upload
  • Click 'Upload`

Mobile web/app

  • Type text in compose box
  • Tap attachment/paperclip icon
  • Tap Photo Library or Choose from Gallery
  • Select photo and tap Choose or Upload to upload

Platform:

Where is this issue occurring?

  • [x] Web
  • [x] iOS
  • [x] Android
  • [x] Desktop App
  • [x] Mobile Web

Version Number: Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/156214 Platform - version: All

Notes/Photos/Videos: Big ol' thread in Slack - link iOS/Messenger is what we're wanting to mimic IMG_5636

IMG_5637

Slack does a good job of handling this but they put they post the text above the image. image

kadiealexander avatar Apr 07 '21 04:04 kadiealexander

Upwork post: https://www.upwork.com/jobs/~01f6625d382eb3f5db

kadiealexander avatar Apr 07 '21 04:04 kadiealexander

Hello, @kadiealexander. How are you? I have a good solution about this issue which can solve simply and perfectly. I've ever implemented it on past projects before. Likewise, I'd love to build a customized component for this feature. The solution is as follows:

  1. Create a composed box which contain drop box and text box.(text box is exist currently).
  2. The drop box is displayed when there is any attachment the user want. And the user select the file, it places on the drop box. If there isn't any attachment, the drop box would be hidden.
  3. When the user clicks the send button, the data of the composed box will be sent together to the target.

What do you think? Looking forward to hearing from you soon.

johndev0711 avatar Apr 10 '21 08:04 johndev0711

Hi @johndev0711 apologies for the delay on this one! We're going to take this issue back into an internal planning stage so that we can get more crisp on details. We'll be sure to update this issue in the near future with crisp details on next steps. Thank you!

JmillsExpensify avatar Apr 13 '21 08:04 JmillsExpensify

Thanks for your info.

johndev0711 avatar Apr 13 '21 11:04 johndev0711

@kadiealexander I see that the old Upwork listing for this issue has been closed. Can you create a new one please so we can push this issue along? As soon as you have the new Upwork posting, please:

  1. Update the E/E tracking issue
  2. Update the OP of this issue with the new Upwork posting
  3. Take this issue off hold

Then we can start taking contributor proposals for this!

roryabraham avatar May 26 '21 17:05 roryabraham

I'm going to assign the External label because a) it hasn't been yet and b) because Rory updated the OP so all the details are there for the post.

mallenexpensify avatar May 26 '21 19:05 mallenexpensify

D'oh, it looks like it stayed assigned to you @kadiealexander cuz you were already assigned (I think). ¯_(ツ)_/¯

mallenexpensify avatar May 26 '21 19:05 mallenexpensify

Latest UpWork post: https://www.upwork.com/jobs/~0102615128016a8557

@johndev0711 thanks for your patience while we refined this. Would you like to keep your proposal in the running here? If you're still interested, could you please have a read of the updated issue and let me know if you think your solution will still apply here?

kadiealexander avatar May 26 '21 21:05 kadiealexander

Previous upwork post was removed, here's the new one: https://www.upwork.com/jobs/~017535f570c71c714a

kadiealexander avatar Jun 04 '21 05:06 kadiealexander

Reached out in Upwork to some contractors we've used in the past to see if they are interested in this project.

Christinadobrzyn avatar Jun 10 '21 03:06 Christinadobrzyn

I have a question about

If the attachment staging area is not empty and/or there is a draft message in the main ReportActionCompose text input, then after switching to a different report and back, or even after closing the app and reopening it, the draft state of the message and the attachments in the staging area should be preserved.

How are we planning to save the images offline? On slack, it uploads all the images while a user is selecting them. Thus next time we see the draft, it just usages the URLs for that purpose. we can't use Onyx for Web. The web has limited storage of 5Mb which will be overflown by these images.

parasharrajat avatar Jun 10 '21 04:06 parasharrajat

How are we planning to save the images offline? On slack, it uploads all the images while a user is selecting them. Thus next time we see the draft, it just usages the URLs for that purpose. we can't use Onyx for Web. The web has limited storage of 5Mb which will be overflown by these images.

You can't use Onyx because Onyx does not have a way to deal with files ATM Even if local storage had tons of space it would be a bad idea to convert a file to base64 string and save it there - local storage / AsyncStorage deals only with strings

Native devices (mobile) have dedicated directories for (documents/cache) that you can leverage to temporary store the file until it's uploaded Browsers have "cache API" that you can use to manually put stuff including files and has a lot more storage space per domain, browsers support IndexedDb as well https://caniuse.com/indexeddb, this technology can be used to cache files: https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/

The above is probably already implemented by some library

What slack does

  • when you have internet access
    • when you select an attachment
    • it starts uploading to slack storage bucket right away
    • if the image is uploaded by the time you press send it sent right away
    • if it's not you'll see a spinner on it, similar to how it works right now in E.cash
    • if you decide to cancel and not send the message - nothing happens. A service is probably clearing the server bucket from images that aren't posted, or the image is cleared when you press cancel
  • when you don't have internet access
    • when you select an attachment
    • it's show a spinner on it
    • if you press send - it goes in the chat with a spinner
    • in a bit you see an error under it - "Couldn't send. Tap to try again"
    • at this point I think they've saved a copy in cache/documents
    • if you regain internet and type more messages
    • then retry the message with attachment that failed - it will move after them, becoming the most recent message

kidroca avatar Jun 10 '21 07:06 kidroca

@kadiealexander @Christinadobrzyn This ticket is listed as a $250 job on Upwork. IMO this is too little for the requirements listed in the description The Offline handling should probably be a separate task on it's own

kidroca avatar Jun 10 '21 07:06 kidroca

I sorta wish we just did the original proposal: send the image and text all at once, and be done with it. This feels like it's massively scope-creeped.

On Thu, Jun 10, 2021 at 12:29 AM Peter Velkov @.***> wrote:

@kadiealexander https://github.com/kadiealexander @Christinadobrzyn https://github.com/Christinadobrzyn This ticket is listed as a $250 job on Upwork. IMO this is too little for the requirements listed in the description The Offline handling should probably be a separate task on it's own

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Expensify/Expensify.cash/issues/2258#issuecomment-858384734, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEMNUSVJKOKVFVPMWVFXCTTSBSWRANCNFSM42P7OVZA .

quinthar avatar Jun 10 '21 07:06 quinthar

@kidroca thanks for your input. I had my plans for using IndexedDB. but I want to know what is the team's original plan for offline caching. I agree this little more involved than a normal task.

And Base64 is a string after all so it can be saved on Local storage/async storage.

Cache API is not a persistent storage solution so we had to go with Indexed DB.

parasharrajat avatar Jun 10 '21 08:06 parasharrajat

Even if local storage had tons of space it would be a bad idea to convert a file to base64 string and save it there - local storage / AsyncStorage deals only with strings

And Base64 is a string after all so it can be saved on Local storage/async storage.

I meant that because AsyncStorage deals only with strings you'd have to use a base64 of the file to save it to AsyncStorage - that's a big NO.

  • Big strings moving through the native bridge
  • Converting a file to base64 - requires reading the file, then converting that to a string - intenisve. Having a reference to a file does not require you to read it - it's read only when it has to be read - displayed or uploaded - and not when passed around
  • Using strings when you can reference files
  • Passing string parameters - JS strings are immutable, strings are copied not passed by reference. Passing 2-3MB or even more per single string is not good

Cache API is not a persistent storage solution so we had to go with Indexed DB.

I thought you needed something until the user is back online, and not to persist files indefinitely I think you might be reinventing the wheel here, why not research for something existing first ?

kidroca avatar Jun 10 '21 10:06 kidroca

Thanks for the clarification. It's more than what I asked and probably not what I asked. Cache storage seems promising. All I am saying is that the main issue description lacks information about storage strategy.

parasharrajat avatar Jun 10 '21 12:06 parasharrajat

Should we go back to this proposal? Upwork post: https://www.upwork.com/jobs/~01f6625d382eb3f5db

Christinadobrzyn avatar Jun 11 '21 00:06 Christinadobrzyn

@Christinadobrzyn I'm not seeing any details related to this issue in that Upwork post.

I sorta wish we just did the original proposal: send the image and text all at once, and be done with it. This feels like it's massively scope-creeped.

It's not really clear to me what you're suggesting – the original proposal in my opinion was a bit half-baked and didn't have a clear answers to a number of questions around how this feature would really work. If we want to reduce the scope of this issue, the following are the items I think we could remove from the scope of this issue and handle in follow-ups:

  • (5) Tapping on any thumbnail in the attachment staging area should open that attachment in the full-screen modal. This time, the modal button should say "Remove" instead of "Attach". Pressing "Remove" should remove the thumbnail from the attachment staging area. Closing the modal without pressing remove should leave the thumbnail in place. The full-screen modal also should not have an option to download the file in the attachment staging area, because that file will have just been uploaded by the user.
  • (9) If the attachment staging area is not empty and/or there is a draft message in the main ReportActionCompose text input, then after switching to a different report and back, or even after closing the app and reopening it, the draft state of the message and the attachments in the staging area should be preserved.

I think that all the other pieces are pretty critical to this feature working as it should. We could also make it so that only one image can be attached at a time, but that seems like an artificial limitation that won't actually reduce the scope of work here by a great deal.

Thoughts? I personally think we should just keep the scope how it is to maintain the offline-first philosophy of Expensify.cash.

All I am saying is that the main issue description lacks information about storage strategy.

This is true, and not something we discussed in the original issue before posting this to Upwork. Let's continue to discuss the best plan forward.

iOS/Android

Native devices (mobile) have dedicated directories for (documents/cache) that you can leverage to temporary store the file until it's uploaded

Would we be able to leverage react-native-fs to achieve this?

Web / Desktop

I unfortunately don't have any experience with IndexedDB but it seems like a promising solution for web. It looks like we can use the same for Electron. I don't think we'll want to use the cache API because it seems like it will end up being "throw away" work for when we do inevitably want to make this work offline-first.

roryabraham avatar Jun 11 '21 16:06 roryabraham

Curious for input from other Expensifiers here too regarding the IndexedDB web API, maybe @AndrewGable, @marcaaron or @cead22?

roryabraham avatar Jun 11 '21 22:06 roryabraham