-
Notifications
You must be signed in to change notification settings - Fork 3k
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: Navigated back to the home screen after granting for Camera permission #47222
Changes from 13 commits
0272c75
bae715a
604ebe3
02bd5f4
222c7b3
77e195a
cf84bd0
ef85f11
f30e704
d2e9ba4
0b54f77
20654ab
1f870b2
46dfb03
e623380
3edf7ea
9031f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -400,6 +400,9 @@ const ONYXKEYS = { | |||||
/** Stores the information about currently edited advanced approval workflow */ | ||||||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anh also update other places to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
|
||||||
/** Collection Keys */ | ||||||
COLLECTION: { | ||||||
DOWNLOAD: 'download_', | ||||||
|
@@ -891,6 +894,7 @@ type OnyxValuesMapping = { | |||||
[ONYXKEYS.NVP_WORKSPACE_TOOLTIP]: OnyxTypes.WorkspaceTooltip; | ||||||
[ONYXKEYS.NVP_PRIVATE_CANCELLATION_DETAILS]: OnyxTypes.CancellationDetails[]; | ||||||
[ONYXKEYS.APPROVAL_WORKFLOW]: OnyxTypes.ApprovalWorkflowOnyx; | ||||||
[ONYXKEYS.LAST_SCREEN]: string; | ||||||
}; | ||||||
|
||||||
type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ import type {FileObject} from '@components/AttachmentModal'; | |||||
import DateUtils from '@libs/DateUtils'; | ||||||
import * as Localize from '@libs/Localize'; | ||||||
import Log from '@libs/Log'; | ||||||
import saveLastScreen from '@libs/saveLastScreen'; | ||||||
import CONST from '@src/CONST'; | ||||||
import getImageManipulator from './getImageManipulator'; | ||||||
import getImageResolution from './getImageResolution'; | ||||||
|
@@ -76,6 +77,9 @@ function showCameraPermissionsAlert() { | |||||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
// we are saving last screen so we can navigate to it after app reload | ||||||
saveLastScreen(); | ||||||
}, | ||||||
}, | ||||||
], | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,6 @@ | ||||||
import {updateLastScreen} from '@libs/actions/App'; | ||||||
import Navigation from '@libs/Navigation/Navigation'; | ||||||
|
||||||
export default function saveLastScreen() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
updateLastScreen(Navigation.getActiveRoute()); | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||||||||
/** we are only saving last screen in case of ios */ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||||||||||
export default function saveLastScreen() {} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ravindra-encoresky ahh my bad, please remove GetPlaidDesktopMessage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import React, {useEffect} from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import {useOnyx, withOnyx} from 'react-native-onyx'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useActiveWorkspaceFromNavigationState from '@hooks/useActiveWorkspaceFromNavigationState'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {updateLastScreen} from '@libs/actions/App'; | ||
import {updateLastAccessedWorkspace} from '@libs/actions/Policy/Policy'; | ||
import * as Browser from '@libs/Browser'; | ||
import TopBar from '@libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar'; | ||
|
@@ -14,6 +16,7 @@ import SidebarLinksData from '@pages/home/sidebar/SidebarLinksData'; | |
import Timing from '@userActions/Timing'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Route} from '@src/ROUTES'; | ||
|
||
/** | ||
* Function called when a pinned chat is selected. | ||
|
@@ -23,7 +26,14 @@ const startTimer = () => { | |
Performance.markStart(CONST.TIMING.SWITCH_REPORT); | ||
}; | ||
|
||
function BaseSidebarScreen() { | ||
type BaseSidebarScreenOnyxProps = { | ||
/** last visited screen */ | ||
lastScreen: OnyxEntry<string>; | ||
}; | ||
|
||
type BaseSidebarScreenProps = BaseSidebarScreenOnyxProps; | ||
|
||
function BaseSidebarScreen({lastScreen}: BaseSidebarScreenProps) { | ||
const styles = useThemeStyles(); | ||
const activeWorkspaceID = useActiveWorkspaceFromNavigationState(); | ||
const {translate} = useLocalize(); | ||
|
@@ -43,6 +53,22 @@ function BaseSidebarScreen() { | |
updateLastAccessedWorkspace(undefined); | ||
}, [activeWorkspace, activeWorkspaceID]); | ||
|
||
/** | ||
* 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you put this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ravindra-encoresky Let's try in Expensify.tsx file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DylanDylann done |
||
if (!lastScreen) { | ||
return; | ||
} | ||
|
||
updateLastScreen(''); | ||
const route = lastScreen as Route; | ||
Navigation.navigate(route); | ||
// disabling this rule, as we want this to run only on the first render | ||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
|
@@ -71,4 +97,8 @@ function BaseSidebarScreen() { | |
|
||
BaseSidebarScreen.displayName = 'BaseSidebarScreen'; | ||
|
||
export default BaseSidebarScreen; | ||
export default withOnyx<BaseSidebarScreenProps, BaseSidebarScreenOnyxProps>({ | ||
lastScreen: { | ||
key: ONYXKEYS.LAST_SCREEN, | ||
}, | ||
})(BaseSidebarScreen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done