fix tests ugh
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m53s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m53s
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user