Don't exclude same source when checking for duplicate entries
Closes #8870
This commit is contained in:
parent
6efcb8ccfa
commit
a0f47d3f1b
@ -48,9 +48,9 @@ class MangaRepositoryImpl(
|
|||||||
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, mangaMapper) }
|
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, mangaMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDuplicateLibraryManga(title: String, sourceId: Long): Manga? {
|
override suspend fun getDuplicateLibraryManga(title: String): Manga? {
|
||||||
return handler.awaitOneOrNull {
|
return handler.awaitOneOrNull {
|
||||||
mangasQueries.getDuplicateLibraryManga(title, sourceId, mangaMapper)
|
mangasQueries.getDuplicateLibraryManga(title, mangaMapper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class GetDuplicateLibraryManga(
|
|||||||
private val mangaRepository: MangaRepository,
|
private val mangaRepository: MangaRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun await(title: String, sourceId: Long): Manga? {
|
suspend fun await(title: String): Manga? {
|
||||||
return mangaRepository.getDuplicateLibraryManga(title.lowercase(), sourceId)
|
return mangaRepository.getDuplicateLibraryManga(title.lowercase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ interface MangaRepository {
|
|||||||
|
|
||||||
fun getFavoritesBySourceId(sourceId: Long): Flow<List<Manga>>
|
fun getFavoritesBySourceId(sourceId: Long): Flow<List<Manga>>
|
||||||
|
|
||||||
suspend fun getDuplicateLibraryManga(title: String, sourceId: Long): Manga?
|
suspend fun getDuplicateLibraryManga(title: String): Manga?
|
||||||
|
|
||||||
suspend fun resetViewerFlags(): Boolean
|
suspend fun resetViewerFlags(): Boolean
|
||||||
|
|
||||||
|
@ -9,14 +9,12 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.Source
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DuplicateMangaDialog(
|
fun DuplicateMangaDialog(
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
onConfirm: () -> Unit,
|
onConfirm: () -> Unit,
|
||||||
onOpenManga: () -> Unit,
|
onOpenManga: () -> Unit,
|
||||||
duplicateFrom: Source,
|
|
||||||
) {
|
) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
@ -46,12 +44,7 @@ fun DuplicateMangaDialog(
|
|||||||
Text(text = stringResource(R.string.are_you_sure))
|
Text(text = stringResource(R.string.are_you_sure))
|
||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Text(
|
Text(text = stringResource(R.string.confirm_add_duplicate_manga))
|
||||||
text = stringResource(
|
|
||||||
id = R.string.confirm_manga_add_duplicate,
|
|
||||||
duplicateFrom.name,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,6 @@ data class BrowseSourceScreen(
|
|||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
onConfirm = { screenModel.addFavorite(dialog.manga) },
|
onConfirm = { screenModel.addFavorite(dialog.manga) },
|
||||||
onOpenManga = { navigator.push(MangaScreen(dialog.duplicate.id)) },
|
onOpenManga = { navigator.push(MangaScreen(dialog.duplicate.id)) },
|
||||||
duplicateFrom = screenModel.getSourceOrStub(dialog.duplicate),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
||||||
|
@ -40,7 +40,6 @@ import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
|||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.filter.CheckboxItem
|
import eu.kanade.tachiyomi.ui.browse.source.filter.CheckboxItem
|
||||||
@ -80,7 +79,7 @@ import eu.kanade.tachiyomi.source.model.Filter as SourceModelFilter
|
|||||||
class BrowseSourceScreenModel(
|
class BrowseSourceScreenModel(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
listingQuery: String?,
|
listingQuery: String?,
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
sourceManager: SourceManager = Injekt.get(),
|
||||||
sourcePreferences: SourcePreferences = Injekt.get(),
|
sourcePreferences: SourcePreferences = Injekt.get(),
|
||||||
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||||
private val coverCache: CoverCache = Injekt.get(),
|
private val coverCache: CoverCache = Injekt.get(),
|
||||||
@ -273,10 +272,6 @@ class BrowseSourceScreenModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSourceOrStub(manga: Manga): Source {
|
|
||||||
return sourceManager.getOrStub(manga.source)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addFavorite(manga: Manga) {
|
fun addFavorite(manga: Manga) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val categories = getCategories()
|
val categories = getCategories()
|
||||||
@ -340,7 +335,7 @@ class BrowseSourceScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDuplicateLibraryManga(manga: Manga): Manga? {
|
suspend fun getDuplicateLibraryManga(manga: Manga): Manga? {
|
||||||
return getDuplicateLibraryManga.await(manga.title, manga.source)
|
return getDuplicateLibraryManga.await(manga.title)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moveMangaToCategories(manga: Manga, vararg categories: Category) {
|
fun moveMangaToCategories(manga: Manga, vararg categories: Category) {
|
||||||
|
@ -169,7 +169,6 @@ class MangaScreen(
|
|||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
onConfirm = { screenModel.toggleFavorite(onRemoved = {}, checkDuplicate = false) },
|
onConfirm = { screenModel.toggleFavorite(onRemoved = {}, checkDuplicate = false) },
|
||||||
onOpenManga = { navigator.push(MangaScreen(dialog.duplicate.id)) },
|
onOpenManga = { navigator.push(MangaScreen(dialog.duplicate.id)) },
|
||||||
duplicateFrom = screenModel.getSourceOrStub(dialog.duplicate),
|
|
||||||
)
|
)
|
||||||
MangaInfoScreenModel.Dialog.SettingsSheet -> ChapterSettingsDialog(
|
MangaInfoScreenModel.Dialog.SettingsSheet -> ChapterSettingsDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
|
@ -82,7 +82,6 @@ class MangaInfoScreenModel(
|
|||||||
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||||
private val uiPreferences: UiPreferences = Injekt.get(),
|
private val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
private val trackManager: TrackManager = Injekt.get(),
|
private val trackManager: TrackManager = Injekt.get(),
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
|
||||||
private val downloadManager: DownloadManager = Injekt.get(),
|
private val downloadManager: DownloadManager = Injekt.get(),
|
||||||
private val downloadCache: DownloadCache = Injekt.get(),
|
private val downloadCache: DownloadCache = Injekt.get(),
|
||||||
private val getMangaAndChapters: GetMangaWithChapters = Injekt.get(),
|
private val getMangaAndChapters: GetMangaWithChapters = Injekt.get(),
|
||||||
@ -272,7 +271,7 @@ class MangaInfoScreenModel(
|
|||||||
// Add to library
|
// Add to library
|
||||||
// First, check if duplicate exists if callback is provided
|
// First, check if duplicate exists if callback is provided
|
||||||
if (checkDuplicate) {
|
if (checkDuplicate) {
|
||||||
val duplicate = getDuplicateLibraryManga.await(manga.title, manga.source)
|
val duplicate = getDuplicateLibraryManga.await(manga.title)
|
||||||
|
|
||||||
if (duplicate != null) {
|
if (duplicate != null) {
|
||||||
mutableState.update { state ->
|
mutableState.update { state ->
|
||||||
@ -926,10 +925,6 @@ class MangaInfoScreenModel(
|
|||||||
|
|
||||||
// Track sheet - end
|
// Track sheet - end
|
||||||
|
|
||||||
fun getSourceOrStub(manga: Manga): Source {
|
|
||||||
return sourceManager.getOrStub(manga.source)
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class Dialog {
|
sealed class Dialog {
|
||||||
data class ChangeCategory(val manga: Manga, val initialSelection: List<CheckboxState<Category>>) : Dialog()
|
data class ChangeCategory(val manga: Manga, val initialSelection: List<CheckboxState<Category>>) : Dialog()
|
||||||
data class DeleteChapters(val chapters: List<Chapter>) : Dialog()
|
data class DeleteChapters(val chapters: List<Chapter>) : Dialog()
|
||||||
|
@ -63,7 +63,6 @@ SELECT *
|
|||||||
FROM mangas
|
FROM mangas
|
||||||
WHERE favorite = 1
|
WHERE favorite = 1
|
||||||
AND LOWER(title) = :title
|
AND LOWER(title) = :title
|
||||||
AND source != :source
|
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
resetViewerFlags:
|
resetViewerFlags:
|
||||||
|
@ -626,7 +626,7 @@
|
|||||||
<!-- missing confirm menu after Compose rewrite #7901 -->
|
<!-- missing confirm menu after Compose rewrite #7901 -->
|
||||||
<string name="remove_from_library">Remove from library</string>
|
<string name="remove_from_library">Remove from library</string>
|
||||||
<string name="unknown_title">Unknown title</string>
|
<string name="unknown_title">Unknown title</string>
|
||||||
<string name="confirm_manga_add_duplicate">You have an entry in your library with the same name but from a different source (%1$s).\n\nDo you still wish to continue?</string>
|
<string name="confirm_add_duplicate_manga">You have an entry in your library with the same name.\n\nDo you still wish to continue?</string>
|
||||||
<string name="manga_added_library">Added to library</string>
|
<string name="manga_added_library">Added to library</string>
|
||||||
<string name="manga_removed_library">Removed from library</string>
|
<string name="manga_removed_library">Removed from library</string>
|
||||||
<string name="manga_info_expand">More</string>
|
<string name="manga_info_expand">More</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user