Don't check year when checking duplicates if year is empty

Some sources don't use year which makes this not match when it really should match
This commit is contained in:
Luna712 2024-04-27 14:09:58 -06:00 committed by GitHub
parent 004c481a5e
commit beaf6b5c97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1099,13 +1099,14 @@ class ResultViewModel2 : ViewModel() {
val duplicateEntries = data.filter { it: DataStoreHelper.LibrarySearchResponse -> val duplicateEntries = data.filter { it: DataStoreHelper.LibrarySearchResponse ->
val librarySyncData = it.syncData val librarySyncData = it.syncData
val yearCheck = year == it.year || year == null || it.year == null
val checks = listOf( val checks = listOf(
{ imdbId != null && getImdbIdFromSyncData(librarySyncData) == imdbId }, { imdbId != null && getImdbIdFromSyncData(librarySyncData) == imdbId },
{ tmdbId != null && getTMDbIdFromSyncData(librarySyncData) == tmdbId }, { tmdbId != null && getTMDbIdFromSyncData(librarySyncData) == tmdbId },
{ malId != null && librarySyncData?.get(AccountManager.malApi.idPrefix) == malId }, { malId != null && librarySyncData?.get(AccountManager.malApi.idPrefix) == malId },
{ aniListId != null && librarySyncData?.get(AccountManager.aniListApi.idPrefix) == aniListId }, { aniListId != null && librarySyncData?.get(AccountManager.aniListApi.idPrefix) == aniListId },
{ normalizedName == normalizeString(it.name) && year == it.year } { normalizedName == normalizeString(it.name) && yearCheck }
) )
checks.any { it() } checks.any { it() }