mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-10 08:18:08 -04:00
Tweak alert dialogs and app startup migration
This commit is contained in:
@@ -179,7 +179,11 @@ export default function CredentialsScreen() : React.ReactNode {
|
||||
* Authentication errors are handled in useVaultSync
|
||||
* For other errors, show alert
|
||||
*/
|
||||
Alert.alert(t('common.error'), error);
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
error,
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
},
|
||||
/**
|
||||
* On upgrade required.
|
||||
|
||||
@@ -289,7 +289,11 @@ export default function Initialize() : React.ReactNode {
|
||||
* Authentication errors are already handled in useVaultSync
|
||||
* Show modal with error message for other errors
|
||||
*/
|
||||
Alert.alert(t('common.error'), error);
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
error,
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
router.replace('/unlock');
|
||||
return;
|
||||
},
|
||||
|
||||
@@ -191,7 +191,11 @@ export default function LoginScreen() : React.ReactNode {
|
||||
checkSuccess = false;
|
||||
|
||||
// Show modal with error message
|
||||
Alert.alert(t('common.error'), message);
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
message,
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
// Error will trigger logout through the sync process
|
||||
setIsLoading(false);
|
||||
},
|
||||
|
||||
@@ -71,7 +71,11 @@ export default function UnlockScreen() : React.ReactNode {
|
||||
*/
|
||||
const handleUnlock = async () : Promise<void> => {
|
||||
if (!password) {
|
||||
Alert.alert(t('common.error'), t('auth.errors.enterPassword'));
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
t('auth.errors.enterPassword'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +117,11 @@ export default function UnlockScreen() : React.ReactNode {
|
||||
*/
|
||||
router.replace('/initialize');
|
||||
} else {
|
||||
Alert.alert(t('common.error'), t('auth.errors.incorrectPassword'));
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
t('auth.errors.incorrectPassword'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof VaultVersionIncompatibleError) {
|
||||
@@ -122,7 +130,11 @@ export default function UnlockScreen() : React.ReactNode {
|
||||
}
|
||||
|
||||
console.error('Unlock error:', error);
|
||||
Alert.alert(t('common.error'), t('auth.errors.incorrectPassword'));
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
t('auth.errors.incorrectPassword'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,11 @@ export default function UpgradeScreen() : React.ReactNode {
|
||||
*/
|
||||
const handleUpgrade = async (): Promise<void> => {
|
||||
if (!sqliteClient || !currentVersion || !latestVersion) {
|
||||
Alert.alert(t('common.error'), t('upgrade.alerts.unableToGetVersionInfo'));
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
t('upgrade.alerts.unableToGetVersionInfo'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,7 +105,11 @@ export default function UpgradeScreen() : React.ReactNode {
|
||||
*/
|
||||
const performUpgrade = async (): Promise<void> => {
|
||||
if (!sqliteClient || !currentVersion || !latestVersion) {
|
||||
Alert.alert(t('common.error'), t('upgrade.alerts.unableToGetVersionInfo'));
|
||||
Alert.alert(
|
||||
t('common.error'),
|
||||
t('upgrade.alerts.unableToGetVersionInfo'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,13 +170,21 @@ export default function UpgradeScreen() : React.ReactNode {
|
||||
*/
|
||||
onError: (error: Error) => {
|
||||
console.error('Upgrade failed:', error);
|
||||
Alert.alert(t('upgrade.alerts.upgradeFailed'), error.message);
|
||||
Alert.alert(
|
||||
t('upgrade.alerts.upgradeFailed'),
|
||||
error.message,
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Upgrade failed:', error);
|
||||
Alert.alert(t('upgrade.alerts.upgradeFailed'), error instanceof Error ? error.message : t('common.errors.unknownError'));
|
||||
Alert.alert(
|
||||
t('upgrade.alerts.upgradeFailed'),
|
||||
error instanceof Error ? error.message : t('common.errors.unknownError'),
|
||||
[{ text: t('common.ok'), style: 'default' }]
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setUpgradeStatus(t('upgrade.status.preparingUpgrade'));
|
||||
|
||||
@@ -139,7 +139,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
*/
|
||||
const initializeAuth = useCallback(async (): Promise<{ isLoggedIn: boolean; enabledAuthMethods: AuthMethod[] }> => {
|
||||
// Sync legacy config to native layer (can be removed in future version 0.25.0+)
|
||||
syncLegacyConfigToNative();
|
||||
// IMPORTANT: We must await this to ensure migration completes before checking auth status
|
||||
await syncLegacyConfigToNative();
|
||||
|
||||
const accessToken = await NativeVaultManager.getAccessToken();
|
||||
const username = await NativeVaultManager.getUsername();
|
||||
@@ -219,7 +220,11 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
|
||||
if (errorMessage) {
|
||||
// Show alert
|
||||
Alert.alert(i18n.t('common.error'), errorMessage);
|
||||
Alert.alert(
|
||||
i18n.t('common.error'),
|
||||
errorMessage,
|
||||
[{ text: i18n.t('common.ok'), style: 'default' }]
|
||||
);
|
||||
}
|
||||
|
||||
setUsername(null);
|
||||
|
||||
Reference in New Issue
Block a user