fix(library): De-duplicate entries mistakenly created in DB

This commit is contained in:
Cuong-Tran 2025-08-15 14:58:34 +07:00
parent 379d36e586
commit 3485297434

View file

@ -552,7 +552,13 @@ class LibraryScreenModel(
// KMK -->
.filterNot { !showHiddenCategories && it.hidden }
// KMK <--
.associateWith { groupCache[it.id]?.toList().orEmpty() }
.associateWith {
groupCache[it.id]?.toList()
// KMK -->
?.distinct()
// KMK <--
.orEmpty()
}
}
// KMK -->
LibraryGroup.UNGROUPED -> {
@ -1019,13 +1025,15 @@ class LibraryScreenModel(
fun removeMangas(mangas: List<Manga>, deleteFromLibrary: Boolean, deleteChapters: Boolean) {
screenModelScope.launchNonCancellable {
if (deleteFromLibrary) {
val toDelete = mangas.map {
it.removeCovers(coverCache)
MangaUpdate(
favorite = false,
id = it.id,
)
}
val toDelete = mangas
.distinctBy { it.id }
.map {
it.removeCovers(coverCache)
MangaUpdate(
favorite = false,
id = it.id,
)
}
updateManga.awaitAll(toDelete)
}
@ -1424,6 +1432,9 @@ class LibraryScreenModel(
// KMK <--
)
}
// KMK -->
.mapValues { (_, values) -> values.distinct() }
// KMK <--
}
LibraryGroup.BY_SOURCE -> {
// KMK -->
@ -1484,7 +1495,7 @@ class LibraryScreenModel(
)
}
// KMK -->
.mapValues { (_, libraryItem) -> libraryItem.fastMap { it.id } }
.mapValues { (_, libraryItem) -> libraryItem.fastMap { it.id }.distinct() }
// KMK <--
}
else -> emptyMap()