bug fixed

This commit is contained in:
Erik Cavazos 2023-09-15 22:15:52 -06:00
parent 0a8946167f
commit 9e8fed5dab
2 changed files with 10 additions and 7 deletions

View File

@ -71,18 +71,15 @@ class CommentsRecyclerViewAdapter(private var list: List<Comment>, private val m
return return
} }
val commentUpdated = updateEvent.affectedPosition?.let { list[it] }
val position = updateEvent.affectedPosition
val position = updateEvent.affectedPosition
previousSize = itemCount previousSize = itemCount
list = updatedList list = updatedList
when(updateEvent.updateType) { when(updateEvent.updateType) {
UpdateEvent.UpdateType.COMMENT_REMOVED -> { UpdateEvent.UpdateType.COMMENT_REMOVED -> {
if(commentUpdated != null && position != null) if(position != null)
notifyItemRemoved(position) notifyItemRemoved(position)
} }
UpdateEvent.UpdateType.COMMENT_ADDED_TOP -> { UpdateEvent.UpdateType.COMMENT_ADDED_TOP -> {

View File

@ -137,7 +137,13 @@ class PostsRecyclerViewAdapter (private val markwon: Markwon, private val callba
notifyDataSetChanged() notifyDataSetChanged()
return return
} }
val postUpdated = updateEvent.affectedPosition?.let { postList?.get(it) } val postUpdated = updateEvent.affectedPosition?.let {
if(updateEvent.updateType == UpdateEvent.UpdateType.POST_REMOVED) {
null
} else {
postList?.get(it)
}
}
val position = updateEvent.affectedPosition val position = updateEvent.affectedPosition
previousSize = itemCount previousSize = itemCount
@ -153,7 +159,7 @@ class PostsRecyclerViewAdapter (private val markwon: Markwon, private val callba
notifyItemChanged(position, CommentsCountUpdatePayload(postUpdated.numberOfComments)) notifyItemChanged(position, CommentsCountUpdatePayload(postUpdated.numberOfComments))
} }
UpdateEvent.UpdateType.POST_REMOVED -> { UpdateEvent.UpdateType.POST_REMOVED -> {
if(postUpdated != null && position != null) if(position != null)
notifyItemRemoved(position) notifyItemRemoved(position)
} }
UpdateEvent.UpdateType.POST_ADDED -> { UpdateEvent.UpdateType.POST_ADDED -> {