From 7478fa9b7f91cf07d06b90c7885efb5d42b9803a Mon Sep 17 00:00:00 2001 From: hassnian Date: Mon, 30 Sep 2024 15:24:01 +0500 Subject: [PATCH] ref(useUpdateProfile.ts): parallel profile image uploading --- composables/useUpdateProfile.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/composables/useUpdateProfile.ts b/composables/useUpdateProfile.ts index aa636d34e1..de46ca2e12 100644 --- a/composables/useUpdateProfile.ts +++ b/composables/useUpdateProfile.ts @@ -23,21 +23,22 @@ export default async ({ hasProfile: boolean useFarcaster: boolean }) => { - const imageUrl = profileData.image - ? await uploadProfileImage({ - file: profileData.image, - type: 'image', - signaturePair, - }) - : profileData.imagePreview - - const bannerUrl = profileData.banner - ? await uploadProfileImage({ - file: profileData.banner, - type: 'banner', - signaturePair, - }) - : profileData.bannerPreview + const [imageUrl, bannerUrl] = await Promise.all([ + profileData.image + ? uploadProfileImage({ + file: profileData.image, + type: 'image', + signaturePair, + }) + : Promise.resolve(profileData.imagePreview), + profileData.banner + ? uploadProfileImage({ + file: profileData.banner, + type: 'banner', + signaturePair, + }) + : Promise.resolve(profileData.bannerPreview), + ]) const profileBody: CreateProfileRequest | UpdateProfileRequest = { address: profileData.address,