Skip to content

Commit

Permalink
Merge pull request #172 from depromeet/feature/issue171
Browse files Browse the repository at this point in the history
프로필 수정 페이지에서 프로필 이미지 변경 할 때 default image 나오게 수정
  • Loading branch information
mjkim1019 authored Jun 20, 2023
2 parents e09fd7a + 3f208f6 commit 0f94b5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SettingProfileViewModel @Inject constructor(
/**
* Network Communication
*/
fun getMe() {
private fun getMe() {
viewModelScope.launch {
userRepository.getMe().collectLatest {
val result = receiveApiResult(it)
Expand Down Expand Up @@ -80,4 +80,4 @@ class SettingProfileViewModel @Inject constructor(
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.depromeet.housekeeper.ui.signIn
import androidx.lifecycle.viewModelScope
import com.depromeet.housekeeper.base.BaseViewModel
import com.depromeet.housekeeper.data.repository.UserRepository
import com.depromeet.housekeeper.model.enums.ProfileViewType
import com.depromeet.housekeeper.model.request.UpdateMember
import com.depromeet.housekeeper.model.response.UpdateMemberResponse
import com.depromeet.housekeeper.model.enums.ProfileViewType
import com.depromeet.housekeeper.util.PrefsManager
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -52,6 +52,10 @@ class SignProfileViewModel @Inject constructor(

fun setViewType(viewType: ProfileViewType) {
_viewType.value = viewType
Timber.d("viewType : $viewType")
if (viewType == ProfileViewType.Modify) {
getMe()
}
}

fun setSelectedImage(imgUrl: String) {
Expand Down Expand Up @@ -97,6 +101,16 @@ class SignProfileViewModel @Inject constructor(
}
}

private fun getMe() {
viewModelScope.launch {
userRepository.getMe().collectLatest {
val result = receiveApiResult(it)
if (result != null) {
_selectedImage.value = result.profilePath
}
}
}
}

data class ProfileState(
val url: String,
Expand Down

0 comments on commit 0f94b5f

Please sign in to comment.