Skip to content

Added attachment size check for videos on native #6588

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

Merged
merged 9 commits into from
Dec 10, 2021

Conversation

akshayasalvi
Copy link
Contributor

@akshayasalvi akshayasalvi commented Dec 6, 2021

Details

Fixed Issues

$ #5918

Tests

  1. Tested video uploads on all platforms
  2. Tested video upload via document picker

QA Steps

  1. Go to any chat and click on Add Attachment
  2. Choose a video greater than the limit (50mb).
  3. Ensure that it throws an error on the attachment size

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

web-video-attachment-limit

Mobile Web

image

Desktop

desktop-video-attachment-limit

iOS

image

Android

Screenshot 2021-12-06 at 6 47 11 PM

@akshayasalvi akshayasalvi requested a review from a team as a code owner December 6, 2021 13:17
@MelvinBot MelvinBot requested review from Beamanator and parasharrajat and removed request for a team December 6, 2021 13:17
Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

Looks great, tests well on native devices! 👍 Just one quick question

@Beamanator
Copy link
Contributor

Also interested in your review @parasharrajat when you have time 👍

@parasharrajat
Copy link
Member

I will do that today. It's on my list.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

There are a few suggestions otherwise looks good.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

NAB: But https://github.com/Expensify/App/pull/6588/files#R244 completeAttachmentSelection is very confusing.
This function should be just initialized on the constructor as noop.

this.completeAttachmentSelection = () => {}

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

NAB: another very confusing code is isValidSize in AttachementModal.js

isValidSize(file) {
return !file || lodashGet(file, 'size', 0) < CONST.API_MAX_ATTACHMENT_SIZE;
}
.

it returns true when file is not present.

@akshayasalvi
Copy link
Contributor Author

@parasharrajat @Beamanator I've updated PR as per comments.

I am not sure about isValidSize(file) and hence I haven't changed that.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

Looks better but one more suggestion before I will test it on platforms.

@parasharrajat
Copy link
Member

I am not sure about isValidSize(file) and hence I haven't changed that.

OK. let's leave it then. In theory, the file will never be null for this function.

parasharrajat
parasharrajat previously approved these changes Dec 9, 2021
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

The code looks good now. Thanks for the changes. cc: @Beamanator


NAB: The only thing I found confusing is that the #6588 (files) completeAttachmentSelection is very confusing.
We should remove this function definition. It is never used. It also uses an unused state variable result which is not consumed anywhere. In action, completeAttachmentSelection is replaced on runtime at L256. I leave this up to you @Beamanator to decide.

    /**
      * Opens the attachment modal
      *
      * @param {function} onPicked A callback that will be called with the selected attachment
      */
    open(onPicked) {
        this.completeAttachmentSelection = onPicked;
        this.setState({isVisible: true});
    }

@Beamanator Beamanator self-requested a review December 9, 2021 10:03
@@ -111,13 +121,15 @@ class AttachmentPicker extends Component {

this.close = this.close.bind(this);
this.pickAttachment = this.pickAttachment.bind(this);
this.completeAttachmentSelection = () => {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say we should not add this for now, but make a separate issue to clean up completeAttachmentSelection - as you said, it looks pretty horrible in this file, but that's not the point of this PR

Copy link
Member

Choose a reason for hiding this comment

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

@akshayasalvi Could you please remove this line based on the request above?

@akshayasalvi
Copy link
Contributor Author

@parasharrajat @Beamanator PR updated with the changes. Thanks for the feedback and helping improve the code.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

I think you missed one pointer.

@@ -111,13 +121,15 @@ class AttachmentPicker extends Component {

this.close = this.close.bind(this);
this.pickAttachment = this.pickAttachment.bind(this);
this.completeAttachmentSelection = () => {};
Copy link
Member

Choose a reason for hiding this comment

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

@akshayasalvi Could you please remove this line based on the request above?

@akshayasalvi
Copy link
Contributor Author

@parasharrajat Done

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

LGTM.

cc: @Beamanator

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

Awesome 👍 Nice work @akshayasalvi and thanks for the helpful reviews @parasharrajat 👍

@Beamanator Beamanator merged commit a35db1e into Expensify:main Dec 10, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @Beamanator in version: 1.1.19-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.21-1 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants