Skip to content

Commit

Permalink
[fix/#45] 친구 조회 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnseo committed Jan 24, 2024
1 parent 7d75b8a commit 014a1e4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.teumteum.teumteum.presentation.mypage.setting.viewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teumteum.domain.entity.Friend
import com.teumteum.domain.entity.FriendMyPage
import com.teumteum.domain.entity.UserInfo
import com.teumteum.domain.repository.AuthRepository
import com.teumteum.domain.repository.UserRepository
Expand All @@ -28,8 +29,8 @@ class MyPageViewModel @Inject constructor(
private val _frontCardState = MutableStateFlow(FrontCard())
val frontCardState: StateFlow<FrontCard> = _frontCardState

private val _friendsList = MutableStateFlow<List<Friend>>(emptyList())
val friendsList : StateFlow<List<Friend>> = _friendsList
private val _friendsList = MutableStateFlow<List<FriendMyPage>>(emptyList())
val friendsList : StateFlow<List<FriendMyPage>> = _friendsList

init {
loadUserInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.teumteum.teumteum.presentation.mypage.setting.viewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teumteum.domain.entity.Friend
import com.teumteum.domain.entity.FriendMyPage
import com.teumteum.domain.entity.UserInfo
import com.teumteum.domain.repository.SettingRepository
import com.teumteum.domain.repository.UserRepository
Expand Down Expand Up @@ -38,10 +39,10 @@ class RecommendDetailViewModel @Inject constructor(
private val _isFriend = MutableStateFlow<Boolean>(false)
val isFriend: StateFlow<Boolean> = _isFriend.asStateFlow()

private val _friendsList = MutableStateFlow<List<Friend>>(emptyList())
val friendsList : StateFlow<List<Friend>> = _friendsList
private val _friendsList = MutableStateFlow<List<FriendMyPage>>(emptyList())
val friendsList : StateFlow<List<FriendMyPage>> = _friendsList

fun checkIfUserIsFriend(friendsList: List<Friend>, userId: Long) {
fun checkIfUserIsFriend(friendsList: List<FriendMyPage>, userId: Long) {
_isFriend.value = friendsList.any { friend -> friend.id.toLong() == userId }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.teumteum.teumteum.presentation.mypage.setting.viewModel
import android.content.Intent
import androidx.annotation.DrawableRes
import com.teumteum.domain.entity.Friend
import com.teumteum.domain.entity.FriendMyPage
import com.teumteum.teumteum.R

data class Meeting(
Expand All @@ -17,7 +18,7 @@ data class Recommend(
val characterId: Int,
)

fun Friend.toRecommend(): Recommend {
fun FriendMyPage.toRecommend(): Recommend {
return Recommend(
id = this.id,
characterId = this.characterId,
Expand Down
10 changes: 9 additions & 1 deletion core/domain/src/main/java/com/teumteum/domain/entity/Friend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ data class Friend(
val mannerTemperature: Int
)

@Serializable
data class FriendMyPage(
val id: Int,
val characterId: Int,
val name: String,
val job: JobEntity,
)

@Serializable
data class Friends(
val friends: List<Friend>
val friends: List<FriendMyPage>
)


Expand Down

0 comments on commit 014a1e4

Please sign in to comment.