Skip to content

Commit

Permalink
[fix/#145] 회원가입 중 카드 수정 시 interest 삭제되는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
blueme0 committed Feb 13, 2024
1 parent 94c538e commit 0def1e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -205,12 +206,14 @@ class SignUpViewModel @Inject constructor(
}

fun setAllInterests(interests: List<String>, selfResource: Array<String>, fieldResource: Array<String>) {
Timber.tag("teum-fix").d("setAllInterests called")
interestSelf.value.clear()
interestField.value.clear()
for (i in interests) {
if (i in selfResource) addInterestSelf(i)
else if (i in fieldResource) addInterestField(i)
}
updateInterestCount()
}

private var _goalText = MutableStateFlow<String>("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.teumteum.teumteum.util.custom.view.model.BackCard
import com.teumteum.teumteum.util.custom.view.model.FrontCard
import com.teumteum.teumteum.util.custom.view.model.Interest
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import java.util.Locale

@AndroidEntryPoint
Expand All @@ -39,6 +40,7 @@ class CardFixFragment
private lateinit var frontAnimation: AnimatorSet
private lateinit var backAnimation: AnimatorSet
private var isFront = true
private var isFirstLoaded = true

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -50,6 +52,7 @@ class CardFixFragment

private fun initCard() {
with(viewModel) {
Timber.tag("teum-fix").d("initCard called")
val fc = CHARACTER_CARD_LIST[characterId.value]?.let {
when (community.value) {
STATUS_WORKER -> FrontCard(userName.value, "@${companyName.value}", jobDetailClass.value,
Expand Down Expand Up @@ -190,9 +193,12 @@ class CardFixFragment
}
}
currentList.observe(viewLifecycleOwner) { interests ->
val selfArray = resources.getStringArray(R.array.interest_1)
val fieldArray = resources.getStringArray(R.array.interest_2)
viewModel.setAllInterests(interests.map { it.toString() }, selfArray, fieldArray)
if (!isFirstLoaded) {
val selfArray = resources.getStringArray(R.array.interest_1)
val fieldArray = resources.getStringArray(R.array.interest_2)
viewModel.setAllInterests(interests.map { it.toString() }, selfArray, fieldArray)
}
isFirstLoaded = false
}
}
}
Expand Down

0 comments on commit 0def1e2

Please sign in to comment.