From bf7505aaf5a11be66a68d136e34bcf301bfb1356 Mon Sep 17 00:00:00 2001 From: shinythinking Date: Tue, 3 Dec 2024 10:00:03 +0900 Subject: [PATCH] =?UTF-8?q?feat/#196=20:=20=EB=82=98=EB=A7=8C=EC=9D=98=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20profileUrl=EB=8F=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/mypage/build.gradle.kts | 1 + .../mapisode/mypage/viewmodel/ProfileEditViewModel.kt | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/feature/mypage/build.gradle.kts b/feature/mypage/build.gradle.kts index 6a0f978b..0c8234f2 100644 --- a/feature/mypage/build.gradle.kts +++ b/feature/mypage/build.gradle.kts @@ -27,4 +27,5 @@ dependencies { implementation(projects.core.auth) implementation(projects.domain.user) implementation(projects.domain.storage) + implementation(projects.domain.mygroup) } diff --git a/feature/mypage/src/main/java/com/boostcamp/mapisode/mypage/viewmodel/ProfileEditViewModel.kt b/feature/mypage/src/main/java/com/boostcamp/mapisode/mypage/viewmodel/ProfileEditViewModel.kt index e70b6c1c..93e82d38 100644 --- a/feature/mypage/src/main/java/com/boostcamp/mapisode/mypage/viewmodel/ProfileEditViewModel.kt +++ b/feature/mypage/src/main/java/com/boostcamp/mapisode/mypage/viewmodel/ProfileEditViewModel.kt @@ -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 @@ -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(ProfileEditState()) { @@ -82,6 +84,7 @@ class ProfileEditViewModel @Inject constructor( private fun editClick() { try { viewModelScope.launch { + updateMyGroupProfileUrl() updateProfileUrl(getStorageUrl()) storeInUserPreferenceDataStore() storeInUserRepository() @@ -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) {