diff --git a/lib/backup/use-user-data-restore.js b/lib/backup/use-user-data-restore.js --- a/lib/backup/use-user-data-restore.js +++ b/lib/backup/use-user-data-restore.js @@ -53,7 +53,7 @@ `Main database version (${mainDatabaseVersion}) is lower than restored` + `database version (${restoredDatabaseVersion}), aborting`, ); - return; + throw new Error('backup_is_newer'); } // 3. Check store versions and migrate if needed @@ -99,7 +99,7 @@ `Main store version (${mainStoreVersion}) is lower than restored` + `store version (${restoredStoreVersion}), aborting`, ); - return; + throw new Error('backup_is_newer'); } // 4. Copy content to main database diff --git a/lib/components/secondary-device-qr-auth-context-provider.react.js b/lib/components/secondary-device-qr-auth-context-provider.react.js --- a/lib/components/secondary-device-qr-auth-context-provider.react.js +++ b/lib/components/secondary-device-qr-auth-context-provider.react.js @@ -204,9 +204,10 @@ 'Error when restoring User Data', getMessageForException(e) ?? 'unknown error', ); + onLogInError(e); } }, - [addLog, userDataRestore], + [addLog, onLogInError, userDataRestore], ); const tunnelbrokerMessageListener = React.useCallback( diff --git a/native/account/restore.js b/native/account/restore.js --- a/native/account/restore.js +++ b/native/account/restore.js @@ -32,6 +32,8 @@ import { useClientBackup } from '../backup/use-client-backup.js'; import { rawGetDeviceListsForUsers } from '../identity-service/identity-service-context-provider.react.js'; import { commCoreModule } from '../native-modules.js'; +import { backupIsNewerThanAppAlertDetails } from '../utils/alert-messages.js'; +import Alert from '../utils/alert.js'; function useRestoreProtocol(): ( // username or wallet address @@ -209,11 +211,18 @@ } const backupData = await commCoreModule.getQRAuthBackupData(); await userDataRestore(backupData, identityAuthResult); - } catch (e) { + } catch (error) { + const messageForException = getMessageForException(error); addLog( 'Error when restoring User Data', - getMessageForException(e) ?? 'unknown error', + messageForException ?? 'unknown error', ); + if (messageForException === 'backup_is_newer') { + Alert.alert( + backupIsNewerThanAppAlertDetails.title, + backupIsNewerThanAppAlertDetails.message, + ); + } } }, [addLog, userDataRestore], diff --git a/native/utils/alert-messages.js b/native/utils/alert-messages.js --- a/native/utils/alert-messages.js +++ b/native/utils/alert-messages.js @@ -47,6 +47,15 @@ 'Failed to contact Comm services. Please check your network connection.', }; +const backupIsNewerThanAppAlertDetails: AlertDetails = { + title: 'App out of date', + message: + `Your app version is pretty old, and restoring your data is not ` + + `possible. Please use the ${platformStore} to update, and then ` + + `we'll restore all your data. If you don't want to do it now, ` + + `you can still use your app.`, +}; + const getFarcasterAccountAlreadyLinkedAlertDetails = ( commUsername: ?string, ): AlertDetails => ({ @@ -63,5 +72,6 @@ userNotFoundAlertDetails, unknownErrorAlertDetails, networkErrorAlertDetails, + backupIsNewerThanAppAlertDetails, getFarcasterAccountAlreadyLinkedAlertDetails, }; diff --git a/native/utils/qr-code-utils.js b/native/utils/qr-code-utils.js --- a/native/utils/qr-code-utils.js +++ b/native/utils/qr-code-utils.js @@ -14,6 +14,7 @@ import * as AES from './aes-crypto-module.js'; import { appOutOfDateAlertDetails, + backupIsNewerThanAppAlertDetails, networkErrorAlertDetails, unknownErrorAlertDetails, } from './alert-messages.js'; @@ -75,6 +76,11 @@ networkErrorAlertDetails.title, networkErrorAlertDetails.message, ); + } else if (messageForException === 'backup_is_newer') { + Alert.alert( + backupIsNewerThanAppAlertDetails.title, + backupIsNewerThanAppAlertDetails.message, + ); } else { Alert.alert( unknownErrorAlertDetails.title, diff --git a/web/utils/qr-code-utils.js b/web/utils/qr-code-utils.js --- a/web/utils/qr-code-utils.js +++ b/web/utils/qr-code-utils.js @@ -21,6 +21,7 @@ import { getMessageForException } from 'lib/utils/errors.js'; import { base64DecodeBuffer, base64EncodeBuffer } from './base64-utils.js'; +import { getBackupIsNewerThanAppError } from './version-utils.js'; import Alert from '../modals/alert.react.js'; import VersionUnsupportedModal from '../modals/version-unsupported-modal.react.js'; @@ -74,6 +75,9 @@ connection. , ); + } else if (messageForException === 'backup_is_newer') { + const message = getBackupIsNewerThanAppError(); + pushModal({message}); } else { pushModal(Uhh... try again?); } diff --git a/web/utils/version-utils.js b/web/utils/version-utils.js --- a/web/utils/version-utils.js +++ b/web/utils/version-utils.js @@ -15,6 +15,20 @@ ); } +function getBackupIsNewerThanAppError(): string { + const actionRequestMessage = isDesktopPlatform( + getConfig().platformDetails.platform, + ) + ? 'Please reload the app' + : 'Please refresh the page'; + return ( + `Your app version is pretty old, and restoring your data is not ` + + `possible. ${actionRequestMessage} to update, and then we'll restore ` + + `all your data. If you don't want to do it now, you can still ` + + `use your app.` + ); +} + function getShortVersionUnsupportedError(): string { const actionRequestMessage = isDesktopPlatform( getConfig().platformDetails.platform, @@ -24,4 +38,8 @@ return `client version unsupported. ${actionRequestMessage}`; } -export { getVersionUnsupportedError, getShortVersionUnsupportedError }; +export { + getVersionUnsupportedError, + getShortVersionUnsupportedError, + getBackupIsNewerThanAppError, +};