From 80e40b3ceb8cf98c1307aaafa4707d43609dadc5 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Wed, 25 Jun 2025 11:41:44 +0200 Subject: [PATCH] Improve mobile app flow for pending migration check (#957) --- apps/mobile-app/app/unlock.tsx | 10 ++++++++-- apps/mobile-app/hooks/useVaultSync.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/mobile-app/app/unlock.tsx b/apps/mobile-app/app/unlock.tsx index 4b5a4d432..e253c6e9f 100644 --- a/apps/mobile-app/app/unlock.tsx +++ b/apps/mobile-app/app/unlock.tsx @@ -23,7 +23,7 @@ import NativeVaultManager from '@/specs/NativeVaultManager'; */ export default function UnlockScreen() : React.ReactNode { const { isLoggedIn, username, isBiometricsEnabled } = useAuth(); - const { testDatabaseConnection } = useDb(); + const dbContext = useDb(); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [isBiometricsAvailable, setIsBiometricsAvailable] = useState(false); @@ -100,7 +100,13 @@ export default function UnlockScreen() : React.ReactNode { const passwordHashBase64 = Buffer.from(passwordHash).toString('base64'); // Initialize the database with the vault response and password - if (await testDatabaseConnection(passwordHashBase64)) { + if (await dbContext.testDatabaseConnection(passwordHashBase64)) { + // Check if the vault is up to date, if not, redirect to the upgrade page. + if (await dbContext.hasPendingMigrations()) { + router.replace('/upgrade'); + return; + } + // Navigate to credentials router.replace('/(tabs)/credentials'); } else { diff --git a/apps/mobile-app/hooks/useVaultSync.ts b/apps/mobile-app/hooks/useVaultSync.ts index 60131a966..e568ad1c4 100644 --- a/apps/mobile-app/hooks/useVaultSync.ts +++ b/apps/mobile-app/hooks/useVaultSync.ts @@ -116,7 +116,7 @@ export const useVaultSync = () : { await dbContext.initializeDatabase(vaultResponseJson as VaultResponse); // Check if the current vault version is known and up to date, if not known trigger an exception, if not up to date redirect to the upgrade page. - if (await dbContext.hasPendingMigrations()) { + if (await NativeVaultManager.isVaultUnlocked() && await dbContext.hasPendingMigrations()) { onUpgradeRequired?.(); return false; }