Skip to content

Commit

Permalink
feat/#196 : 나만의 그룹 profileUrl도 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
shinythinking committed Dec 3, 2024
1 parent 27c19f6 commit fc23d56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions feature/mypage/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ dependencies {
implementation(projects.core.auth)
implementation(projects.domain.user)
implementation(projects.domain.storage)
implementation(projects.domain.mygroup)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.boostcamp.mapisode.mypage.viewmodel

import androidx.lifecycle.viewModelScope
import com.boostcamp.mapisode.datastore.UserPreferenceDataStore
import com.boostcamp.mapisode.mygroup.GroupRepository
import com.boostcamp.mapisode.mypage.R
import com.boostcamp.mapisode.mypage.intent.ProfileEditIntent
import com.boostcamp.mapisode.mypage.sideeffect.ProfileEditSideEffect
Expand All @@ -17,6 +18,7 @@ import javax.inject.Inject
@HiltViewModel
class ProfileEditViewModel @Inject constructor(
private val storageRepository: StorageRepository,
private val groupRepository: GroupRepository,
private val userRepository: UserRepository,
private val userPreferenceDataStore: UserPreferenceDataStore,
) : BaseViewModel<ProfileEditIntent, ProfileEditState, ProfileEditSideEffect>(ProfileEditState()) {
Expand Down Expand Up @@ -82,6 +84,7 @@ class ProfileEditViewModel @Inject constructor(
private fun editClick() {
try {
viewModelScope.launch {
updateMyGroupProfileUrl()
updateProfileUrl(getStorageUrl())
storeInUserPreferenceDataStore()
storeInUserRepository()
Expand All @@ -103,6 +106,13 @@ class ProfileEditViewModel @Inject constructor(
}
}

private suspend fun updateMyGroupProfileUrl() {
viewModelScope.launch {
val myGroup = groupRepository.getGroupByGroupId(currentState.uid)
groupRepository.updateGroup(myGroup.copy(imageUrl = currentState.profileUrl))
}
}

private suspend fun storeInUserPreferenceDataStore() {
viewModelScope.launch {
with(userPreferenceDataStore) {
Expand Down

0 comments on commit fc23d56

Please sign in to comment.