Skip to content

Commit

Permalink
#172 feat : Signup 사진 있을때 없을때 분기처리 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
plashdof committed Dec 6, 2023
1 parent e27403f commit 022f341
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ interface IntroApi {
@Part profileImage: MultipartBody.Part
): Response<Unit>

@Multipart
@POST("api/user")
suspend fun signupNoImage(
@Part("email") email: RequestBody,
@Part("password") password: RequestBody,
@Part("provider") provider: RequestBody,
@Part("nickName") nickName: RequestBody,
@Part("region") region: RequestBody,
@Part("birthdate") birthdate: RequestBody,
@Part("isMale") isMale: Boolean,
): Response<Unit>

@POST("api/auth/social-login")
suspend fun loginNaver(
@Header("Authorization") token: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,37 @@ class IntroRepositoryImpl @Inject constructor(
region: RequestBody,
birthdate: RequestBody,
isMale: Boolean,
profileImage: MultipartBody.Part
profileImage: MultipartBody.Part?
): Flow<BaseState<Unit>> = flow {
val result = runRemote {
api.signup(
email,
password,
provider,
nickName,
region,
birthdate,
isMale,
profileImage
)
profileImage?.let { image ->
val result = runRemote {
api.signup(
email,
password,
provider,
nickName,
region,
birthdate,
isMale,
image
)
}
emit(result)
} ?: run {
val result = runRemote {
api.signupNoImage(
email,
password,
provider,
nickName,
region,
birthdate,
isMale,
)
}
emit(result)
}
emit(result)

}

override fun loginNaver(token: String): Flow<BaseState<LoginData>> = flow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface IntroRepository {
region: RequestBody,
birthdate: RequestBody,
isMale: Boolean,
profileImage: MultipartBody.Part
profileImage: MultipartBody.Part?
): Flow<BaseState<Unit>>

fun loginNaver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ class DetailSignupFragment :
}
}

private fun initImageObserver(){
private fun initImageObserver() {
repeatOnStarted {
parentViewModel.image.collect{
viewModel.setImage(it, it.toMultiPart(requireContext()))
parentViewModel.image.collect {
if (it.isNotBlank()) {
viewModel.setImage(it, it.toMultiPart(requireContext(), "profileImage"))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DetailSignupViewModel @Inject constructor(
val birth = MutableStateFlow("")
val location = MutableStateFlow("")
val profileImg = MutableStateFlow("")
private lateinit var profileFile: MultipartBody.Part
private var profileFile: MultipartBody.Part? = null

val isDataReady =
combine(
Expand Down

0 comments on commit 022f341

Please sign in to comment.