Avoid showing duplicate entry dialog for same entry
Fixes #9772 (cherry picked from commit fd30c0adcdfc0efc0aae9e5401843439f2622070)
This commit is contained in:
parent
cc297da44a
commit
9760cb101d
@ -430,7 +430,7 @@ open class BrowseSourceScreenModel(
|
||||
}
|
||||
|
||||
suspend fun getDuplicateLibraryManga(manga: Manga): Manga? {
|
||||
return getDuplicateLibraryManga.await(manga.title)
|
||||
return getDuplicateLibraryManga.await(manga).getOrNull(0)
|
||||
}
|
||||
|
||||
private fun moveMangaToCategories(manga: Manga, vararg categories: Category) {
|
||||
|
@ -705,7 +705,7 @@ class MangaScreenModel(
|
||||
// Add to library
|
||||
// First, check if duplicate exists if callback is provided
|
||||
if (checkDuplicate) {
|
||||
val duplicate = getDuplicateLibraryManga.await(manga.title)
|
||||
val duplicate = getDuplicateLibraryManga.await(manga).getOrNull(0)
|
||||
|
||||
if (duplicate != null) {
|
||||
updateSuccessState { it.copy(dialog = Dialog.DuplicateManga(manga, duplicate)) }
|
||||
|
@ -55,9 +55,9 @@ class MangaRepositoryImpl(
|
||||
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, mangaMapper) }
|
||||
}
|
||||
|
||||
override suspend fun getDuplicateLibraryManga(title: String): Manga? {
|
||||
return handler.awaitOneOrNull {
|
||||
mangasQueries.getDuplicateLibraryManga(title, mangaMapper)
|
||||
override suspend fun getDuplicateLibraryManga(id: Long, title: String): List<Manga> {
|
||||
return handler.awaitList {
|
||||
mangasQueries.getDuplicateLibraryManga(title, id, mangaMapper)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ SELECT *
|
||||
FROM mangas
|
||||
WHERE favorite = 1
|
||||
AND LOWER(title) = :title
|
||||
LIMIT 1;
|
||||
AND _id != :id;
|
||||
|
||||
resetViewerFlags:
|
||||
UPDATE mangas
|
||||
|
@ -7,7 +7,7 @@ class GetDuplicateLibraryManga(
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(title: String): Manga? {
|
||||
return mangaRepository.getDuplicateLibraryManga(title.lowercase())
|
||||
suspend fun await(manga: Manga): List<Manga> {
|
||||
return mangaRepository.getDuplicateLibraryManga(manga.id, manga.title.lowercase())
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ interface MangaRepository {
|
||||
|
||||
fun getFavoritesBySourceId(sourceId: Long): Flow<List<Manga>>
|
||||
|
||||
suspend fun getDuplicateLibraryManga(title: String): Manga?
|
||||
suspend fun getDuplicateLibraryManga(id: Long, title: String): List<Manga>
|
||||
|
||||
suspend fun resetViewerFlags(): Boolean
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user