Skip to content

Commit

Permalink
[IDLE-000] 센터 정보 등록 란에서 이미지가 등록되지 않던 것 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Nov 21, 2024
1 parent cc9e4e9 commit 4e01ac9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.idle.domain.usecase.profile

import com.idle.domain.model.auth.UserType
import com.idle.domain.repositorry.profile.ProfileRepository
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import javax.inject.Inject

class RegisterCenterProfileUseCase @Inject constructor(
Expand All @@ -12,13 +15,36 @@ class RegisterCenterProfileUseCase @Inject constructor(
introduce: String,
lotNumberAddress: String,
officeNumber: String,
roadNameAddress: String
) = profileRepository.registerCenterProfile(
centerName = centerName,
detailedAddress = detailedAddress,
introduce = introduce,
lotNumberAddress = lotNumberAddress,
officeNumber = officeNumber,
roadNameAddress = roadNameAddress
)
roadNameAddress: String,
imageFileUri: String?,
) = runCatching {
coroutineScope {
val registerProfileJob = launch {
profileRepository.registerCenterProfile(
centerName = centerName,
detailedAddress = detailedAddress,
introduce = introduce,
lotNumberAddress = lotNumberAddress,
officeNumber = officeNumber,
roadNameAddress = roadNameAddress
).getOrThrow()
}

val updateProfileImageJob = imageFileUri?.let { uri ->
if (uri.startsWith("content://")) {
launch {
profileRepository.updateProfileImage(
userType = UserType.CENTER.apiValue,
imageFileUri = uri,
reqWidth = 1340,
reqHeight = 1016,
).getOrThrow()
}
} else null
}

registerProfileJob.join()
updateProfileImageJob?.join()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UpdateCenterProfileUseCase @Inject constructor(
imageFileUri: String?,
): Result<Unit> = runCatching {
coroutineScope {
val updateProfileJon = launch {
val updateProfileJob = launch {
profileRepository.updateCenterProfile(
officeNumber = officeNumber,
introduce = introduce,
Expand All @@ -35,7 +35,7 @@ class UpdateCenterProfileUseCase @Inject constructor(
} else null
}

updateProfileJon.join()
updateProfileJob.join()
updateProfileImageJob?.join()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class RegisterCenterInfoViewModel @Inject constructor(
introduce = _centerIntroduce.value,
lotNumberAddress = _lotNumberAddress.value,
officeNumber = _centerNumber.value,
roadNameAddress = _roadNameAddress.value
roadNameAddress = _roadNameAddress.value,
imageFileUri = _centerProfileImageUri.value.toString(),
).onSuccess {
navigationHelper.navigateTo(
com.idle.navigation.NavigationEvent.NavigateTo(
Expand Down

0 comments on commit 4e01ac9

Please sign in to comment.