@@ -422,56 +422,59 @@ class CodePush implements CodePushCapacitorPlugin {
422422 } ;
423423
424424 const onUpdate = async ( remotePackage : RemotePackage ) => {
425- const updateShouldBeIgnored = remotePackage && ( remotePackage . failedInstall && syncOptions . ignoreFailedUpdates ) ;
426- if ( updateShouldBeIgnored ) {
427- CodePushUtil . logMessage ( "An update is available, but it is being ignored due to have been previously rolled back." ) ;
428-
429- syncCallback && syncCallback ( null , SyncStatus . UPDATE_IGNORED ) ;
425+ if ( remotePackage === null ) {
426+ /* Then the app is up to date */
427+ syncCallback && syncCallback ( null , SyncStatus . UP_TO_DATE ) ;
430428 } else {
431- const dlgOpts : UpdateDialogOptions = < UpdateDialogOptions > syncOptions . updateDialog ;
432- if ( dlgOpts ) {
433- CodePushUtil . logMessage ( "Awaiting user action." ) ;
434- syncCallback && syncCallback ( null , SyncStatus . AWAITING_USER_ACTION ) ;
435- }
436-
437- if ( remotePackage === null ) {
438- /* Then the app is up to date */
439- syncCallback && syncCallback ( null , SyncStatus . UP_TO_DATE ) ;
440- } else if ( remotePackage . isMandatory && syncOptions . updateDialog ) {
441- /* Alert user */
442- const message = dlgOpts . appendReleaseDescription ?
443- dlgOpts . mandatoryUpdateMessage + dlgOpts . descriptionPrefix + remotePackage . description
444- : dlgOpts . mandatoryUpdateMessage ;
445- await Dialog . alert ( {
446- message,
447- title : dlgOpts . updateTitle ,
448- buttonTitle : dlgOpts . mandatoryContinueButtonLabel
449- } ) ;
450- downloadAndInstallUpdate ( remotePackage ) ;
451- } else if ( ! remotePackage . isMandatory && syncOptions . updateDialog ) {
452- /* Confirm update with user */
453- const message = dlgOpts . appendReleaseDescription ?
454- dlgOpts . optionalUpdateMessage + dlgOpts . descriptionPrefix + remotePackage . description
455- : dlgOpts . optionalUpdateMessage ;
456-
457- const confirmResult : ConfirmResult = await Dialog . confirm ( {
458- message,
459- title : dlgOpts . updateTitle ,
460- okButtonTitle : dlgOpts . optionalInstallButtonLabel ,
461- cancelButtonTitle : dlgOpts . optionalIgnoreButtonLabel
462- } ) ;
463-
464- if ( confirmResult . value === true ) {
465- /* Install */
466- downloadAndInstallUpdate ( remotePackage ) ;
429+ if ( remotePackage . failedInstall && syncOptions . ignoreFailedUpdates ) {
430+ CodePushUtil . logMessage ( "An update is available, but it is being ignored due to have been previously rolled back." ) ;
431+ syncCallback && syncCallback ( null , SyncStatus . UPDATE_IGNORED ) ;
432+ } else {
433+ if ( syncOptions . updateDialog ) {
434+ CodePushUtil . logMessage ( "Awaiting user action." ) ;
435+ syncCallback && syncCallback ( null , SyncStatus . AWAITING_USER_ACTION ) ;
436+
437+ const dlgOpts : UpdateDialogOptions = < UpdateDialogOptions > syncOptions . updateDialog ;
438+
439+ if ( remotePackage . isMandatory ) {
440+ /* Alert user */
441+ const message = dlgOpts . appendReleaseDescription ?
442+ dlgOpts . mandatoryUpdateMessage + dlgOpts . descriptionPrefix + remotePackage . description :
443+ dlgOpts . mandatoryUpdateMessage ;
444+ await Dialog . alert (
445+ {
446+ message,
447+ title : dlgOpts . updateTitle ,
448+ buttonTitle : dlgOpts . mandatoryContinueButtonLabel
449+ }
450+ ) ;
451+ downloadAndInstallUpdate ( remotePackage ) ;
452+ } else {
453+ /* Confirm update with user */
454+ const message = dlgOpts . appendReleaseDescription ?
455+ dlgOpts . optionalUpdateMessage + dlgOpts . descriptionPrefix + remotePackage . description
456+ : dlgOpts . optionalUpdateMessage ;
457+
458+ const confirmResult : ConfirmResult = await Dialog . confirm ( {
459+ message,
460+ title : dlgOpts . updateTitle ,
461+ okButtonTitle : dlgOpts . optionalInstallButtonLabel ,
462+ cancelButtonTitle : dlgOpts . optionalIgnoreButtonLabel
463+ } ) ;
464+
465+ if ( confirmResult . value === true ) {
466+ /* Install */
467+ downloadAndInstallUpdate ( remotePackage ) ;
468+ } else {
469+ /* Cancel */
470+ CodePushUtil . logMessage ( "User cancelled the update." ) ;
471+ syncCallback && syncCallback ( null , SyncStatus . UPDATE_IGNORED ) ;
472+ }
473+ }
467474 } else {
468- /* Cancel */
469- CodePushUtil . logMessage ( "User cancelled the update." ) ;
470- syncCallback && syncCallback ( null , SyncStatus . UPDATE_IGNORED ) ;
475+ /* No user interaction */
476+ downloadAndInstallUpdate ( remotePackage ) ;
471477 }
472- } else {
473- /* No user interaction */
474- downloadAndInstallUpdate ( remotePackage ) ;
475478 }
476479 }
477480 } ;
0 commit comments