check for a deployment before prompting to apply it
Reloading into an update re-delivers the deep link that triggered it, and the same link can also just be tapped again. Checking first means both cases are silent when there is nothing new to apply - the version mismatch warning no longer fires ahead of the check either. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,9 +94,9 @@ export function useIntentHandler() {
|
||||
: null
|
||||
if (!channel) {
|
||||
Alert.alert('Error', 'No channel provided to look for.')
|
||||
} else {
|
||||
tryApplyUpdate(channel, appVersion)
|
||||
return
|
||||
}
|
||||
tryApplyUpdate(channel, appVersion)
|
||||
return
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -168,6 +168,12 @@ export function useApplyPullRequestOTAUpdate() {
|
||||
updateId: fetchedUpdate.manifest.id,
|
||||
})
|
||||
try {
|
||||
/*
|
||||
* TODO: once expo-linking is upgraded to >= 57, enable this so the
|
||||
* re-delivered initial URL doesn't trigger a redundant silent check
|
||||
* after the reload.
|
||||
*/
|
||||
// Linking.clearInitialURL()
|
||||
await reloadAsync()
|
||||
} catch (e) {
|
||||
device.remove(['pendingOTAUpdate'])
|
||||
@@ -186,29 +192,35 @@ export function useApplyPullRequestOTAUpdate() {
|
||||
})()
|
||||
}
|
||||
|
||||
if (declaredAppVersion && declaredAppVersion !== APP_VERSION) {
|
||||
Alert.alert(
|
||||
'App Version Mismatch',
|
||||
`This OTA update was built for a different version of the app.\n\nCurrent app version: ${APP_VERSION}\nOTA app version: ${declaredAppVersion}\n\nApplying it anyway may cause the app to stop working and require a reinstall.`,
|
||||
[
|
||||
{
|
||||
text: 'Cancel',
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'Apply Anyway',
|
||||
style: 'destructive',
|
||||
onPress: applyUpdate,
|
||||
},
|
||||
],
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
* Check before prompting about anything, so that re-running this while
|
||||
* already on the newest update of `channel` stays silent. Reloading into an
|
||||
* update re-delivers the deep link that triggered it, and the same link may
|
||||
* also just be tapped again.
|
||||
*/
|
||||
setPending(true)
|
||||
try {
|
||||
if (!(await checkForDeployment())) return
|
||||
|
||||
if (declaredAppVersion && declaredAppVersion !== APP_VERSION) {
|
||||
Alert.alert(
|
||||
'App Version Mismatch',
|
||||
`This OTA update was built for a different version of the app.\n\nCurrent app version: ${APP_VERSION}\nOTA app version: ${declaredAppVersion}\n\nApplying it anyway may cause the app to stop working and require a reinstall.`,
|
||||
[
|
||||
{
|
||||
text: 'Cancel',
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'Apply Anyway',
|
||||
style: 'destructive',
|
||||
onPress: applyUpdate,
|
||||
},
|
||||
],
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Alert.alert(
|
||||
`Apply update from ${deploymentName}?`,
|
||||
'The app will relaunch after the update is applied.',
|
||||
|
||||
Reference in New Issue
Block a user