-> 아이디로 피드를 찾아올때 user의 타입이 DocumentReference로 되어있어 바꿔주어야함 (nickname)
class FeedRemote @Inject constructor(
private val firestore: FirebaseFirestore
) : GetFeedList {
override suspend fun getFeedList(
uid: String?,
limit: Long?,
startAfter: String?
): List<FeedModel> {
val feedDocuments = firestore.collection("feed")
.get()
.await()
.documents
Log.d("FeedRemote", "getFeedList: $feedDocuments")
return feedDocuments.mapNotNull { documentSnapshot ->
val tagList = documentSnapshot.get("tagList") as? List<*>
documentSnapshot.toObject(FeedModel::class.java)?.copy(
feedId = documentSnapshot.id,
tags = tagList?.filterIsInstance<String>() ?: emptyList()
)
?.run {
val nickname =
(user as? DocumentReference)?.get()?.await()?.getString("nickname")
// 로그로 nickname 값을 출력하여 확인
Log.d("FeedRemote", "Fetched nickname: $nickname for user: ${user?.id}")
nickname?.let {
copy(nickname = it)
} ?: this
}
}
}