Skip to content

Added attachment size check for videos on native#6588

Merged
Beamanator merged 9 commits into
Expensify:mainfrom
akshayasalvi:attachment-size-err
Dec 10, 2021
Merged

Added attachment size check for videos on native#6588
Beamanator merged 9 commits into
Expensify:mainfrom
akshayasalvi:attachment-size-err

Conversation

@akshayasalvi

@akshayasalvi akshayasalvi commented Dec 6, 2021

Copy link
Copy Markdown
Contributor

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

@Beamanator Beamanator left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/components/AttachmentPicker/index.native.js Outdated
@Beamanator

Copy link
Copy Markdown
Contributor

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

@parasharrajat

Copy link
Copy Markdown
Member

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

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/components/AttachmentPicker/index.native.js Outdated
Comment thread src/components/AttachmentPicker/index.native.js Outdated
Comment thread src/components/AttachmentPicker/index.native.js Outdated
Comment thread src/components/AttachmentPicker/index.native.js Outdated

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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 = () => {}

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/components/AttachmentPicker/index.native.js Outdated
@parasharrajat

Copy link
Copy Markdown
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.

Comment thread src/components/AttachmentPicker/index.native.js
parasharrajat
parasharrajat previously approved these changes Dec 9, 2021

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown
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
Copy Markdown
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?

Comment thread src/components/AttachmentPicker/index.native.js Outdated
akshayasalvi and others added 3 commits December 9, 2021 17:06
@akshayasalvi

Copy link
Copy Markdown
Contributor Author

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

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

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.


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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

@parasharrajat Done

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

cc: @Beamanator

@Beamanator Beamanator left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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