-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32326 from Expensify/marcaaron-forceAppUpgrade
Handle API errors to trigger force upgrades of the app
- Loading branch information
Showing
24 changed files
with
195 additions
and
39 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as Link from '@userActions/Link'; | ||
import CONST from '@src/CONST'; | ||
|
||
export default function updateApp() { | ||
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.ANDROID); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {Linking} from 'react-native'; | ||
import CONST from '@src/CONST'; | ||
|
||
export default function updateApp() { | ||
Linking.openURL(CONST.APP_DOWNLOAD_LINKS.DESKTOP); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as Link from '@userActions/Link'; | ||
import CONST from '@src/CONST'; | ||
|
||
export default function updateApp() { | ||
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.IOS); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* On web or mWeb we can simply refresh the page and the user should have the new version of the app downloaded. | ||
*/ | ||
export default function updateApp() { | ||
window.location.reload(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import getEnvironment from '@libs/Environment/getEnvironment'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
function alertUser() { | ||
// For now, we will pretty much never have to do this on a platform other than production. | ||
// We should only update the minimum app version in the API after all platforms of a new version have been deployed to PRODUCTION. | ||
// As staging is always ahead of production there is no reason to "force update" those apps. | ||
getEnvironment().then((environment) => { | ||
if (environment !== CONST.ENVIRONMENT.PRODUCTION) { | ||
return; | ||
} | ||
|
||
Onyx.set(ONYXKEYS.UPDATE_REQUIRED, true); | ||
}); | ||
} | ||
|
||
export { | ||
// eslint-disable-next-line import/prefer-default-export | ||
alertUser, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import Button from '@components/Button'; | ||
import Header from '@components/Header'; | ||
import HeaderGap from '@components/HeaderGap'; | ||
import Lottie from '@components/Lottie'; | ||
import LottieAnimations from '@components/LottieAnimations'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useSafeAreaInsets from '@hooks/useSafeAreaInsets'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import * as AppUpdate from '@libs/actions/AppUpdate'; | ||
|
||
function UpdateRequiredView() { | ||
const insets = useSafeAreaInsets(); | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
const {translate} = useLocalize(); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
return ( | ||
<View style={[styles.appBG, styles.h100, StyleUtils.getSafeAreaPadding(insets)]}> | ||
<HeaderGap /> | ||
<View style={[styles.pt5, styles.ph5, styles.updateRequiredViewHeader]}> | ||
<Header title={translate('updateRequiredView.updateRequired')} /> | ||
</View> | ||
<View style={[styles.flex1, StyleUtils.getUpdateRequiredViewStyles(isSmallScreenWidth)]}> | ||
<Lottie | ||
source={LottieAnimations.Update} | ||
// For small screens it looks better to have the arms from the animation come in from the edges of the screen. | ||
style={isSmallScreenWidth ? styles.w100 : styles.updateAnimation} | ||
webStyle={isSmallScreenWidth ? styles.w100 : styles.updateAnimation} | ||
autoPlay | ||
loop | ||
/> | ||
<View style={[styles.ph5, styles.alignItemsCenter, styles.mt5]}> | ||
<View style={styles.updateRequiredViewTextContainer}> | ||
<View style={[styles.mb3]}> | ||
<Text style={[styles.newKansasLarge, styles.textAlignCenter]}>{translate('updateRequiredView.pleaseInstall')}</Text> | ||
</View> | ||
<View style={styles.mb5}> | ||
<Text style={[styles.textAlignCenter, styles.textSupporting]}>{translate('updateRequiredView.toGetLatestChanges')}</Text> | ||
</View> | ||
</View> | ||
</View> | ||
<Button | ||
success | ||
large | ||
onPress={() => AppUpdate.updateApp()} | ||
text={translate('common.update')} | ||
style={styles.updateRequiredViewTextContainer} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
UpdateRequiredView.displayName = 'UpdateRequiredView'; | ||
export default UpdateRequiredView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.