Merge pull request #2134 from Kruna1Pate1/fix/watch-history

Fix watch history deletion
This commit is contained in:
Bnyro 2022-11-28 16:15:57 +01:00 committed by GitHub
commit 494bd083d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -21,8 +21,9 @@ class WatchHistoryAdapter(
RecyclerView.Adapter<WatchHistoryViewHolder>() {
fun removeFromWatchHistory(position: Int) {
val history = watchHistory[position]
query {
DatabaseHolder.Database.watchHistoryDao().delete(watchHistory[position])
DatabaseHolder.Database.watchHistoryDao().delete(history)
}
watchHistory.removeAt(position)
notifyItemRemoved(position)

View File

@ -89,7 +89,7 @@ class WatchHistoryFragment : BaseFragment() {
// observe changes
watchHistoryAdapter.registerAdapterDataObserver(object :
RecyclerView.AdapterDataObserver() {
override fun onChanged() {
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
if (watchHistoryAdapter.itemCount == 0) {
binding.watchHistoryRecView.visibility = View.GONE
binding.historyEmpty.visibility = View.VISIBLE