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

Fix iOS file downloads #14215

Merged
merged 1 commit into from
Jan 11, 2023
Merged

Fix iOS file downloads #14215

merged 1 commit into from
Jan 11, 2023

Conversation

luacmartins
Copy link
Contributor

@luacmartins luacmartins commented Jan 10, 2023

Details

Bubbles the promise rejection so we can handle it appropriately.

Fixed Issues

$ #14206

Tests

  1. Send a video attachment, eg .mp4
  2. After it upload tap on the icon to download the file
  3. Decline the permission to access your camera roll
  4. Verify that there is no infinite loading spinner
  5. Tap the download icon again, tap Allow
  6. You will be navigated to the iOS Settings
  7. Add the Add Photos Only permission
  8. Go back to the App
  9. Tap the download icon again and verify that you can successfully download the file
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Only iOS is applicable since the changes are done to an index.ios.js file

Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
ios.mov
Android

@luacmartins luacmartins self-assigned this Jan 10, 2023
@luacmartins luacmartins marked this pull request as ready for review January 10, 2023 22:59
@luacmartins luacmartins requested a review from a team as a code owner January 10, 2023 22:59
@melvin-bot melvin-bot bot requested review from MariaHCD and rushatgabhane and removed request for a team January 10, 2023 23:00
@melvin-bot
Copy link

melvin-bot bot commented Jan 10, 2023

@rushatgabhane @MariaHCD One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@rushatgabhane
Copy link
Member

Send an mp4 or mp3 attachment
After it upload tap on the icon to download the file
Decline the permission to access your camera roll

@luacmartins I'm on main branch and have declined pemission to camera roll.
I'm still able to download mp3, pdfs.

This is because they don't need camera roll permissions.

Screen.Recording.2023-01-11.at.10.25.07.AM.mov

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

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

Send an mp4 or mp3 attachment

suggestion: change test step to dealing with videos only. (mp4 / mov etc)

@luacmartins
Copy link
Contributor Author

Nice catch! Updated!

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

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

@luacmartins LGTM as well! Tested that this isn't an issue on Android / iOS.

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Screen.Recording.2023-01-12.at.1.57.24.AM.mov
Android
WhatsApp.Video.2023-01-12.at.02.06.29.mp4

@luacmartins
Copy link
Contributor Author

Thanks for the reviews! Merging!

@luacmartins luacmartins merged commit 096f175 into main Jan 11, 2023
@luacmartins luacmartins deleted the cmartins-fixIOSDownload branch January 11, 2023 20:40
@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.

@github-actions
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
App start TTI 672.169 ms → 695.043 ms (+22.874 ms, +3.4%)
App start runJsBundle 178.032 ms → 193.548 ms (+15.516 ms, +8.7%)
App start nativeLaunch 10.419 ms → 19.688 ms (+9.268 ms, +89.0%) 🟡
App start regularAppStart 0.015 ms → 0.015 ms (-0.000 ms, ±0.0%)
Open Search Page TTI 604.514 ms → 603.281 ms (-1.234 ms, ±0.0%)
Show details
Name Duration
App start TTI Baseline
Mean: 672.169 ms
Stdev: 29.181 ms (4.3%)
Runs: 607.134733999148 637.225694000721 637.8468009997159 649.1998510006815 649.7164900004864 650.5158259999007 651.182909000665 654.1414689999074 654.377473000437 655.2727150004357 655.4070759993047 659.3708549998701 659.3821569997817 660.6384059991688 661.2173699997365 661.9678670000285 663.5296909995377 667.154882999137 667.5278730001301 667.9562340006232 670.1263519991189 680.0406030006707 685.6808499991894 690.2881400007755 691.3651449996978 704.2310409992933 705.8762309998274 708.6350640002638 709.1956939995289 714.377263000235 736.9462279994041 741.8889719992876

Current
Mean: 695.043 ms
Stdev: 39.410 ms (5.7%)
Runs: 644.3000920005143 651.4347239993513 653.2796739991754 653.5751680005342 657.7959230002016 658.6318549998105 663.6553179994226 664.9143059998751 667.8978059999645 670.2180739995092 671.6782050002366 675.1020459998399 675.3289039991796 679.2556909993291 679.9253470003605 680.199883999303 683.4933599997312 695.453185999766 696.1858530007303 701.7692360002548 704.4524450004101 708.3278490006924 716.8604090008885 717.237113000825 726.5254999995232 728.2428859993815 733.2512069996446 735.9817680008709 751.9175220001489 785.1431699991226 814.3011249992996
App start runJsBundle Baseline
Mean: 178.032 ms
Stdev: 16.657 ms (9.4%)
Runs: 149 153 158 158 159 160 162 163 164 166 170 172 173 173 177 179 180 180 181 181 184 187 188 188 193 194 197 205 207 209 209

Current
Mean: 193.548 ms
Stdev: 20.991 ms (10.8%)
Runs: 166 168 170 172 173 173 173 177 177 179 180 182 182 183 185 187 188 189 192 199 201 207 211 213 214 218 220 221 223 230 247
App start nativeLaunch Baseline
Mean: 10.419 ms
Stdev: 1.880 ms (18.0%)
Runs: 8 8 8 8 8 9 9 9 9 9 9 9 9 10 10 10 11 11 11 11 11 11 11 12 12 12 13 13 13 14 15

Current
Mean: 19.688 ms
Stdev: 2.142 ms (10.9%)
Runs: 17 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 20 20 20 21 21 21 22 23 25 25 25
App start regularAppStart Baseline
Mean: 0.015 ms
Stdev: 0.002 ms (12.9%)
Runs: 0.01228800043463707 0.012369999662041664 0.012613998726010323 0.012736000120639801 0.012899000197649002 0.012980001047253609 0.013101998716592789 0.013224000111222267 0.013345999643206596 0.013387000188231468 0.013589998707175255 0.013630999252200127 0.013631001114845276 0.013712000101804733 0.013793999329209328 0.0139979999512434 0.014038000255823135 0.014444999396800995 0.01489199884235859 0.015095999464392662 0.015340998768806458 0.01586899906396866 0.01607299968600273 0.016154000535607338 0.01619499921798706 0.016642000526189804 0.01700899936258793 0.017619000747799873 0.018230000510811806 0.01827000081539154 0.019328000023961067

Current
Mean: 0.015 ms
Stdev: 0.001 ms (4.7%)
Runs: 0.013508999720215797 0.013630999252200127 0.013753000646829605 0.013874998316168785 0.014078998938202858 0.014120001345872879 0.014200998470187187 0.014201000332832336 0.014201000332832336 0.014241999015212059 0.0143630001693964 0.0143630001693964 0.01440499909222126 0.014444999396800995 0.01448499970138073 0.014485001564025879 0.014608001336455345 0.014729999005794525 0.014770999550819397 0.014770999550819397 0.014852000400424004 0.015096001327037811 0.015177000313997269 0.015217998996376991 0.015258999541401863 0.015422001481056213 0.015461999922990799 0.015461999922990799 0.0157880000770092 0.0167239997535944
Open Search Page TTI Baseline
Mean: 604.514 ms
Stdev: 16.423 ms (2.7%)
Runs: 564.0040280018002 579.343791000545 580.8277589995414 582.6525889988989 587.028279999271 589.4573160000145 590.8016769997776 591.4166669994593 595.015909999609 595.913697000593 596.8795170001686 600.594360999763 600.7731529995799 605.1650799997151 605.6915690004826 606.106119999662 608.3078620005399 608.5729989986867 609.362671000883 610.1079510003328 610.5965580008924 610.644206000492 611.9247639998794 612.5022790003568 614.4896240010858 616.2563889995217 617.2942299991846 618.0540360007435 619.2840170003474 621.5730800013989 641.8883060012013 641.9333089999855

Current
Mean: 603.281 ms
Stdev: 17.967 ms (3.0%)
Runs: 561.5552980005741 566.0421150010079 577.9971110001206 579.7172040008008 588.4156090002507 590.0257569998503 590.9596770014614 592.6838390007615 594.5498050004244 596.648072000593 597.4777429997921 599.4238690007478 599.9204520005733 601.5557460002601 602.4324539992958 603.7486569993198 604.2499189991504 605.3882240001112 605.9684250000864 606.1833900008351 606.8971759993583 606.9899899996817 607.7721770014614 607.9340009987354 610.8213299997151 616.87915099971 620.3720709998161 623.317220998928 626.3861490003765 630.3083899989724 640.6327320002019 641.7295329999179

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @luacmartins in version: 1.2.53-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.2.53-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 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