From 7270c48f26bf61780aca5f588c742839fd3e9c2f Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Mon, 12 Sep 2022 23:29:28 +0700 Subject: [PATCH] LibraryItem: Fix equality check (#7999) Proper equality check is needed by compose for state changes. --- .../tachiyomi/ui/library/LibraryItem.kt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index 21d6c6317..11e39afd3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -67,13 +67,30 @@ class LibraryItem( } override fun equals(other: Any?): Boolean { - if (other is LibraryItem) { - return manga.id == other.manga.id - } - return false + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as LibraryItem + + if (manga != other.manga) return false + if (sourceManager != other.sourceManager) return false + if (displayMode != other.displayMode) return false + if (downloadCount != other.downloadCount) return false + if (unreadCount != other.unreadCount) return false + if (isLocal != other.isLocal) return false + if (sourceLanguage != other.sourceLanguage) return false + + return true } override fun hashCode(): Int { - return manga.id!!.hashCode() + var result = manga.hashCode() + result = 31 * result + sourceManager.hashCode() + result = 31 * result + displayMode.hashCode() + result = 31 * result + downloadCount + result = 31 * result + unreadCount + result = 31 * result + isLocal.hashCode() + result = 31 * result + sourceLanguage.hashCode() + return result } }