Fix CategoryListModel equals/hashcode

pull/166/head
Koitharu 4 years ago
parent 930819ffa2
commit 6405523232
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -40,7 +40,10 @@ class CategoriesAdapter(
newItem: CategoryListModel, newItem: CategoryListModel,
): Any? = when { ): Any? = when {
oldItem is CategoryListModel.All && newItem is CategoryListModel.All -> Unit oldItem is CategoryListModel.All && newItem is CategoryListModel.All -> Unit
else -> super.getChangePayload(oldItem, newItem) oldItem is CategoryListModel.CategoryItem &&
newItem is CategoryListModel.CategoryItem &&
oldItem.category.title != newItem.category.title -> null
else -> Unit
} }
} }
} }

@ -45,6 +45,7 @@ sealed interface CategoryListModel : ListModel {
if (category.id != other.category.id) return false if (category.id != other.category.id) return false
if (category.title != other.category.title) return false if (category.title != other.category.title) return false
if (category.order != other.category.order) return false if (category.order != other.category.order) return false
if (category.isTrackingEnabled != other.category.isTrackingEnabled) return false
return true return true
} }
@ -53,6 +54,7 @@ sealed interface CategoryListModel : ListModel {
var result = category.id.hashCode() var result = category.id.hashCode()
result = 31 * result + category.title.hashCode() result = 31 * result + category.title.hashCode()
result = 31 * result + category.order.hashCode() result = 31 * result + category.order.hashCode()
result = 31 * result + category.isTrackingEnabled.hashCode()
return result return result
} }
} }

Loading…
Cancel
Save