fix tests ugh
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m53s

This commit is contained in:
2025-12-09 18:48:17 -08:00
parent 4674309ea1
commit 23e0c44b61
10 changed files with 89 additions and 79 deletions

View File

@@ -119,23 +119,28 @@ export const ProfileManager: React.FC<ProfileManagerProps> = ({ isOpen, onClose,
}
try {
// Update profile and address in parallel
// Use Promise.allSettled to ensure both API calls complete, regardless of individual success or failure.
// This prevents a race condition where a successful call could trigger a state update before a failed call's error is handled.
const profileUpdatePromise = updateProfile({
full_name: fullName,
avatar_url: avatarUrl,
});
const addressUpdatePromise = updateAddress(address);
const [profileResponse] = await Promise.all([
const [profileResult, addressResult] = await Promise.allSettled([
profileUpdatePromise,
addressUpdatePromise
]);
if (profileResponse) { // profileResponse can be null if useApi fails
onProfileUpdate(profileResponse);
// Only proceed if both operations were successful. The useApi hook handles individual error notifications.
if (profileResult.status === 'fulfilled' && addressResult.status === 'fulfilled') {
if (profileResult.value) { // The value can be null if useApi fails internally but doesn't throw
onProfileUpdate(profileResult.value);
}
notifySuccess('Profile and address updated successfully!');
onClose();
}
notifySuccess('Profile and address updated successfully!');
onClose();
} catch (error) {
// Although the useApi hook is designed to handle errors, we log here
// as a safeguard to catch any unexpected issues during profile save.