@@ -12,12 +12,14 @@ import com.whyranoid.domain.model.RecruitPost
12
12
import com.whyranoid.domain.model.RunningPost
13
13
import com.whyranoid.presentation.databinding.ItemRecruitPostBinding
14
14
import com.whyranoid.presentation.databinding.ItemRunningPostBinding
15
+ import com.whyranoid.presentation.model.GroupInfoUiModel
15
16
16
17
class PostAdapter (
17
- private val myUid : String ,
18
18
private val buttonClickListener : (String ) -> Unit
19
19
) : ListAdapter<Post, PostAdapter.PostViewHolder>(diffUtil) {
20
20
21
+ private lateinit var myGroupList: List <GroupInfoUiModel >
22
+
21
23
companion object {
22
24
val diffUtil = object : DiffUtil .ItemCallback <Post >() {
23
25
override fun areItemsTheSame (oldItem : Post , newItem : Post ) =
@@ -48,7 +50,7 @@ class PostAdapter(
48
50
if (post is RecruitPost ) {
49
51
with (binding) {
50
52
recruitPost = post
51
- if (myUid == post.author.uid ) {
53
+ if (post.groupInfo.groupId in myGroupList.map { it.groupId } ) {
52
54
btnJoinGroup.visibility = View .GONE
53
55
} else {
54
56
btnJoinGroup.visibility = View .VISIBLE
@@ -93,4 +95,8 @@ class PostAdapter(
93
95
override fun onBindViewHolder (holder : PostViewHolder , position : Int ) {
94
96
holder.bind(getItem(position))
95
97
}
98
+
99
+ fun setMyGroupList (myGroupList : List <GroupInfoUiModel >) {
100
+ this .myGroupList = myGroupList
101
+ }
96
102
}
0 commit comments