Fix: Navigated back to the home screen after granting for Camera permission#47222
Conversation
|
@DylanDylann Please 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] |
| Linking.openSettings(); | ||
| // In case of ios, app reload when we enable camera permission from settings | ||
| // we are saving last screen so we can navigate to it after app reload | ||
| if (getPlatform() === CONST.PLATFORM.IOS && screenName) { |
There was a problem hiding this comment.
Don't use getPlatform function. Let's create a new .ios file
There was a problem hiding this comment.
created FileUtils.ios.ts file
There was a problem hiding this comment.
@ravindra-encoresky Ops, Don't need to create a new FileUtils.ios.ts. WƯe should introduce a new function, this function only be available on .ios file, and this func will be empty on other platforms. Then we use this function in showCameraPermissionsAlert func
There was a problem hiding this comment.
@DylanDylann Do you want something like this?
Under src/lib/updateLastScreen
- index.ts - will have empty updateLastScreen function
- index.ios.ts - will have updateLastScreen function to save last screen
and I updateLastScreen will be called from showCameraPermissionsAlert
There was a problem hiding this comment.
@ravindra-encoresky Yes. We should avoid making duplicated code when creating new FileUtils.ts
| } | ||
| interceptAnonymousUser(() => { | ||
| updateLastScreen(''); | ||
| IOU.startMoneyRequest( |
|
@ravindra-encoresky Hi, how about the above comments? |
|
Also please record videos on all platforms to ensure that your change don't break any other things |
|
@DylanDylann hi, yes checked the comments. I'll add the changes soon. Sure will add the video as well. |
|
@ravindra-encoresky Friendly bump |
@DylanDylann I'm on it, all things done, just have to push it, due to the holidays here wasn't able to. I'll do it earliest. thanks. |
|
@ravindra-encoresky Bump on this comment: #47222 (comment) |
|
|
||
| if (status === RESULTS.BLOCKED) { | ||
| FileUtils.showCameraPermissionsAlert(); | ||
| FileUtils.showCameraPermissionsAlert({screenName: SCREENS.RIGHT_MODAL.MONEY_REQUEST, iouType}); |
There was a problem hiding this comment.
@ravindra-encoresky I think we should save the current route in Onyx (using Navigation.getActiveRoute function)
There was a problem hiding this comment.
yes, you are correct. I am making necessary changes
There was a problem hiding this comment.
@DylanDylann i have made the necessary changes to use activeRoute and it is working as expected
| * Navigate to scan receipt screen after it enabling camera permission from setting | ||
| * This will only works for ios application because we are saving last screen only for ios | ||
| */ | ||
| useEffect(() => { |
There was a problem hiding this comment.
Why do you put this useEffect into this file?
There was a problem hiding this comment.
I couldn't find any other file for navigating to the Receipt Scan screen when the app opens. btw I looking to optimise it by using activeRoute instead of hardcoding last screen.
There was a problem hiding this comment.
@DylanDylann Another screen where I could place this useEffect is SidebarScreen.tsx. Please let me know if I’m missing any part of the flow for this.
There was a problem hiding this comment.
@ravindra-encoresky Let's try in Expensify.tsx file
I have added videos for all platforms except iOS Safari, as the camera doesn’t work in the Safari browser on the emulator. Additionally, I am unable to find a way to run the mobile web version on a physical iOS device. |
| APPROVAL_WORKFLOW: 'approvalWorkflow', | ||
|
|
||
| /** screen to open after reloading app after changing app permission from settings */ | ||
| LAST_SCREEN: 'last_screen', |
There was a problem hiding this comment.
| LAST_SCREEN: 'last_screen', | |
| LAST_ROUTE: 'lastRoute', |
There was a problem hiding this comment.
Anh also update other places to use route instead of screen
| /** Stores the information about currently edited advanced approval workflow */ | ||
| APPROVAL_WORKFLOW: 'approvalWorkflow', | ||
|
|
||
| /** screen to open after reloading app after changing app permission from settings */ |
There was a problem hiding this comment.
| /** screen to open after reloading app after changing app permission from settings */ | |
| /** Stores the route to open after changing app permission from settings */ |
| import {updateLastScreen} from '@libs/actions/App'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
||
| export default function saveLastScreen() { |
There was a problem hiding this comment.
| export default function saveLastScreen() { | |
| export default function saveLastRoute() { |
| text: Localize.translateLocal('common.settings'), | ||
| onPress: () => { | ||
| Linking.openSettings(); | ||
| // In case of ios, app reload when we enable camera permission from settings |
There was a problem hiding this comment.
| // In case of ios, app reload when we enable camera permission from settings | |
| // In the case of ios, the App reloads when we update camera permission from settings |
| @@ -0,0 +1,3 @@ | |||
| /** we are only saving last screen in case of ios */ | |||
There was a problem hiding this comment.
| /** we are only saving last screen in case of ios */ |
| @@ -0,0 +1,3 @@ | |||
| /** we are only saving last screen in case of ios */ | |||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | |||
| export default function saveLastScreen() {} | |||
There was a problem hiding this comment.
| export default function saveLastScreen() {} | |
| const saveLastRoute: GetPlaidDesktopMessage = () => {}; | |
| export default saveLastRoute; | |
There was a problem hiding this comment.
@DylanDylann There is a issue of type mismatch for return (Type 'void' is not assignable to type 'TranslationPaths | undefined)
There was a problem hiding this comment.
@ravindra-encoresky ahh my bad, please remove GetPlaidDesktopMessage
| lastVisitedPath: { | ||
| key: ONYXKEYS.LAST_VISITED_PATH, | ||
| }, | ||
| lastRoute: { |
|
Some minor comments, @ravindra-encoresky Could you address them soon? |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-26.at.14.51.07.movAndroid: mWeb ChromeScreen.Recording.2024-08-26.at.14.58.44.moviOS: NativeScreen.Recording.2024-08-26.at.14.59.42.moviOS: mWeb SafariScreenRecording_08-26-2024.15-16-14_1.MP4MacOS: Chrome / SafariScreen.Recording.2024-08-26.at.15.03.45.movMacOS: DesktopScreen.Recording.2024-08-26.at.15.03.29.mov |
Done |
| Audio.setAudioModeAsync({playsInSilentModeIOS: true}); | ||
| }, []); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Wondering if we should replace this with a useLayoutEffect so that we can run Navigation.navigate to route to the correct screen before the first paint of Expensify.tsx
There was a problem hiding this comment.
Done.
Tested again, working perfectly.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.0.26-1 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.26-6 🚀
|
Details
Fixed Issues
$ #46422
PROPOSAL: $ #46422 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android_web.mov
iOS: Native
355539874-76950b43-82cc-444f-bd0f-99fa09ef6bdc.mov
iOS: mWeb Safari
Only iOS Native affectedMacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov