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
|
: null
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
Alert.alert('Error', 'No channel provided to look for.')
|
Alert.alert('Error', 'No channel provided to look for.')
|
||||||
} else {
|
return
|
||||||
tryApplyUpdate(channel, appVersion)
|
|
||||||
}
|
}
|
||||||
|
tryApplyUpdate(channel, appVersion)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -168,6 +168,12 @@ export function useApplyPullRequestOTAUpdate() {
|
|||||||
updateId: fetchedUpdate.manifest.id,
|
updateId: fetchedUpdate.manifest.id,
|
||||||
})
|
})
|
||||||
try {
|
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()
|
await reloadAsync()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
device.remove(['pendingOTAUpdate'])
|
device.remove(['pendingOTAUpdate'])
|
||||||
@@ -186,29 +192,35 @@ export function useApplyPullRequestOTAUpdate() {
|
|||||||
})()
|
})()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaredAppVersion && declaredAppVersion !== APP_VERSION) {
|
/*
|
||||||
Alert.alert(
|
* Check before prompting about anything, so that re-running this while
|
||||||
'App Version Mismatch',
|
* already on the newest update of `channel` stays silent. Reloading into an
|
||||||
`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.`,
|
* update re-delivers the deep link that triggered it, and the same link may
|
||||||
[
|
* also just be tapped again.
|
||||||
{
|
*/
|
||||||
text: 'Cancel',
|
|
||||||
style: 'cancel',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Apply Anyway',
|
|
||||||
style: 'destructive',
|
|
||||||
onPress: applyUpdate,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setPending(true)
|
setPending(true)
|
||||||
try {
|
try {
|
||||||
if (!(await checkForDeployment())) return
|
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(
|
Alert.alert(
|
||||||
`Apply update from ${deploymentName}?`,
|
`Apply update from ${deploymentName}?`,
|
||||||
'The app will relaunch after the update is applied.',
|
'The app will relaunch after the update is applied.',
|
||||||
|
|||||||
Reference in New Issue
Block a user