Fix CategoryListModel equals/hashcode

This commit is contained in:
Koitharu
2022-05-07 08:50:33 +03:00
parent 930819ffa2
commit 6405523232
2 changed files with 6 additions and 1 deletions

View File

@@ -40,7 +40,10 @@ class CategoriesAdapter(
newItem: CategoryListModel,
): Any? = when {
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
}
}
}

View File

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