mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Minor cleanup
This commit is contained in:
parent
7e92921f84
commit
bc1fbfac9d
@ -109,9 +109,9 @@ class MangaRepositoryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun updateAll(values: List<MangaUpdate>): Boolean {
|
override suspend fun updateAll(mangaUpdates: List<MangaUpdate>): Boolean {
|
||||||
return try {
|
return try {
|
||||||
partialUpdate(*values.toTypedArray())
|
partialUpdate(*mangaUpdates.toTypedArray())
|
||||||
true
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logcat(LogPriority.ERROR, e)
|
logcat(LogPriority.ERROR, e)
|
||||||
@ -119,9 +119,9 @@ class MangaRepositoryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun partialUpdate(vararg values: MangaUpdate) {
|
private suspend fun partialUpdate(vararg mangaUpdates: MangaUpdate) {
|
||||||
handler.await(inTransaction = true) {
|
handler.await(inTransaction = true) {
|
||||||
values.forEach { value ->
|
mangaUpdates.forEach { value ->
|
||||||
mangasQueries.update(
|
mangasQueries.update(
|
||||||
source = value.source,
|
source = value.source,
|
||||||
url = value.url,
|
url = value.url,
|
||||||
|
@ -44,9 +44,9 @@ class TrackRepositoryImpl(
|
|||||||
insertValues(*tracks.toTypedArray())
|
insertValues(*tracks.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun insertValues(vararg values: Track) {
|
private suspend fun insertValues(vararg tracks: Track) {
|
||||||
handler.await(inTransaction = true) {
|
handler.await(inTransaction = true) {
|
||||||
values.forEach { mangaTrack ->
|
tracks.forEach { mangaTrack ->
|
||||||
manga_syncQueries.insert(
|
manga_syncQueries.insert(
|
||||||
mangaId = mangaTrack.mangaId,
|
mangaId = mangaTrack.mangaId,
|
||||||
syncId = mangaTrack.syncId,
|
syncId = mangaTrack.syncId,
|
||||||
|
@ -32,7 +32,7 @@ import eu.kanade.domain.download.interactor.DeleteDownload
|
|||||||
import eu.kanade.domain.extension.interactor.GetExtensionLanguages
|
import eu.kanade.domain.extension.interactor.GetExtensionLanguages
|
||||||
import eu.kanade.domain.extension.interactor.GetExtensionSources
|
import eu.kanade.domain.extension.interactor.GetExtensionSources
|
||||||
import eu.kanade.domain.extension.interactor.GetExtensionsByType
|
import eu.kanade.domain.extension.interactor.GetExtensionsByType
|
||||||
import eu.kanade.domain.history.interactor.DeleteHistoryTable
|
import eu.kanade.domain.history.interactor.DeleteAllHistory
|
||||||
import eu.kanade.domain.history.interactor.GetHistory
|
import eu.kanade.domain.history.interactor.GetHistory
|
||||||
import eu.kanade.domain.history.interactor.GetNextChapter
|
import eu.kanade.domain.history.interactor.GetNextChapter
|
||||||
import eu.kanade.domain.history.interactor.RemoveHistoryById
|
import eu.kanade.domain.history.interactor.RemoveHistoryById
|
||||||
@ -117,7 +117,7 @@ class DomainModule : InjektModule {
|
|||||||
addFactory { SyncChaptersWithTrackServiceTwoWay(get(), get()) }
|
addFactory { SyncChaptersWithTrackServiceTwoWay(get(), get()) }
|
||||||
|
|
||||||
addSingletonFactory<HistoryRepository> { HistoryRepositoryImpl(get()) }
|
addSingletonFactory<HistoryRepository> { HistoryRepositoryImpl(get()) }
|
||||||
addFactory { DeleteHistoryTable(get()) }
|
addFactory { DeleteAllHistory(get()) }
|
||||||
addFactory { GetHistory(get()) }
|
addFactory { GetHistory(get()) }
|
||||||
addFactory { UpsertHistory(get()) }
|
addFactory { UpsertHistory(get()) }
|
||||||
addFactory { RemoveHistoryById(get()) }
|
addFactory { RemoveHistoryById(get()) }
|
||||||
|
@ -4,9 +4,8 @@ import eu.kanade.domain.category.model.Category
|
|||||||
import eu.kanade.domain.category.model.anyWithName
|
import eu.kanade.domain.category.model.anyWithName
|
||||||
import eu.kanade.domain.category.repository.CategoryRepository
|
import eu.kanade.domain.category.repository.CategoryRepository
|
||||||
import eu.kanade.domain.library.service.LibraryPreferences
|
import eu.kanade.domain.library.service.LibraryPreferences
|
||||||
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import kotlinx.coroutines.NonCancellable
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
class CreateCategoryWithName(
|
class CreateCategoryWithName(
|
||||||
@ -22,10 +21,10 @@ class CreateCategoryWithName(
|
|||||||
sort.direction.flag
|
sort.direction.flag
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun await(name: String): Result = withContext(NonCancellable) {
|
suspend fun await(name: String): Result = withNonCancellableContext {
|
||||||
val categories = categoryRepository.getAll()
|
val categories = categoryRepository.getAll()
|
||||||
if (categories.anyWithName(name)) {
|
if (categories.anyWithName(name)) {
|
||||||
return@withContext Result.NameAlreadyExistsError
|
return@withNonCancellableContext Result.NameAlreadyExistsError
|
||||||
}
|
}
|
||||||
|
|
||||||
val nextOrder = categories.maxOfOrNull { it.order }?.plus(1) ?: 0
|
val nextOrder = categories.maxOfOrNull { it.order }?.plus(1) ?: 0
|
||||||
|
@ -2,21 +2,20 @@ package eu.kanade.domain.category.interactor
|
|||||||
|
|
||||||
import eu.kanade.domain.category.model.CategoryUpdate
|
import eu.kanade.domain.category.model.CategoryUpdate
|
||||||
import eu.kanade.domain.category.repository.CategoryRepository
|
import eu.kanade.domain.category.repository.CategoryRepository
|
||||||
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import kotlinx.coroutines.NonCancellable
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
class DeleteCategory(
|
class DeleteCategory(
|
||||||
private val categoryRepository: CategoryRepository,
|
private val categoryRepository: CategoryRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun await(categoryId: Long) = withContext(NonCancellable) {
|
suspend fun await(categoryId: Long) = withNonCancellableContext {
|
||||||
try {
|
try {
|
||||||
categoryRepository.delete(categoryId)
|
categoryRepository.delete(categoryId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logcat(LogPriority.ERROR, e)
|
logcat(LogPriority.ERROR, e)
|
||||||
return@withContext Result.InternalError(e)
|
return@withNonCancellableContext Result.InternalError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
val categories = categoryRepository.getAll()
|
val categories = categoryRepository.getAll()
|
||||||
|
@ -4,19 +4,18 @@ import eu.kanade.domain.category.model.Category
|
|||||||
import eu.kanade.domain.category.model.CategoryUpdate
|
import eu.kanade.domain.category.model.CategoryUpdate
|
||||||
import eu.kanade.domain.category.model.anyWithName
|
import eu.kanade.domain.category.model.anyWithName
|
||||||
import eu.kanade.domain.category.repository.CategoryRepository
|
import eu.kanade.domain.category.repository.CategoryRepository
|
||||||
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import kotlinx.coroutines.NonCancellable
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
class RenameCategory(
|
class RenameCategory(
|
||||||
private val categoryRepository: CategoryRepository,
|
private val categoryRepository: CategoryRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun await(categoryId: Long, name: String) = withContext(NonCancellable) {
|
suspend fun await(categoryId: Long, name: String) = withNonCancellableContext {
|
||||||
val categories = categoryRepository.getAll()
|
val categories = categoryRepository.getAll()
|
||||||
if (categories.anyWithName(name)) {
|
if (categories.anyWithName(name)) {
|
||||||
return@withContext Result.NameAlreadyExistsError
|
return@withNonCancellableContext Result.NameAlreadyExistsError
|
||||||
}
|
}
|
||||||
|
|
||||||
val update = CategoryUpdate(
|
val update = CategoryUpdate(
|
||||||
|
@ -3,21 +3,20 @@ package eu.kanade.domain.category.interactor
|
|||||||
import eu.kanade.domain.category.model.Category
|
import eu.kanade.domain.category.model.Category
|
||||||
import eu.kanade.domain.category.model.CategoryUpdate
|
import eu.kanade.domain.category.model.CategoryUpdate
|
||||||
import eu.kanade.domain.category.repository.CategoryRepository
|
import eu.kanade.domain.category.repository.CategoryRepository
|
||||||
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import kotlinx.coroutines.NonCancellable
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
class ReorderCategory(
|
class ReorderCategory(
|
||||||
private val categoryRepository: CategoryRepository,
|
private val categoryRepository: CategoryRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun await(categoryId: Long, newPosition: Int) = withContext(NonCancellable) {
|
suspend fun await(categoryId: Long, newPosition: Int) = withNonCancellableContext {
|
||||||
val categories = categoryRepository.getAll().filterNot(Category::isSystemCategory)
|
val categories = categoryRepository.getAll().filterNot(Category::isSystemCategory)
|
||||||
|
|
||||||
val currentIndex = categories.indexOfFirst { it.id == categoryId }
|
val currentIndex = categories.indexOfFirst { it.id == categoryId }
|
||||||
if (currentIndex == newPosition) {
|
if (currentIndex == newPosition) {
|
||||||
return@withContext Result.Unchanged
|
return@withNonCancellableContext Result.Unchanged
|
||||||
}
|
}
|
||||||
|
|
||||||
val reorderedCategories = categories.toMutableList()
|
val reorderedCategories = categories.toMutableList()
|
||||||
|
@ -2,14 +2,13 @@ package eu.kanade.domain.category.interactor
|
|||||||
|
|
||||||
import eu.kanade.domain.category.model.CategoryUpdate
|
import eu.kanade.domain.category.model.CategoryUpdate
|
||||||
import eu.kanade.domain.category.repository.CategoryRepository
|
import eu.kanade.domain.category.repository.CategoryRepository
|
||||||
import kotlinx.coroutines.NonCancellable
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
|
|
||||||
class UpdateCategory(
|
class UpdateCategory(
|
||||||
private val categoryRepository: CategoryRepository,
|
private val categoryRepository: CategoryRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun await(payload: CategoryUpdate): Result = withContext(NonCancellable) {
|
suspend fun await(payload: CategoryUpdate): Result = withNonCancellableContext {
|
||||||
try {
|
try {
|
||||||
categoryRepository.updatePartial(payload)
|
categoryRepository.updatePartial(payload)
|
||||||
Result.Success
|
Result.Success
|
||||||
|
@ -7,9 +7,8 @@ import eu.kanade.domain.download.interactor.DeleteDownload
|
|||||||
import eu.kanade.domain.download.service.DownloadPreferences
|
import eu.kanade.domain.download.service.DownloadPreferences
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.repository.MangaRepository
|
import eu.kanade.domain.manga.repository.MangaRepository
|
||||||
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import kotlinx.coroutines.NonCancellable
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
class SetReadStatus(
|
class SetReadStatus(
|
||||||
@ -27,38 +26,28 @@ class SetReadStatus(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun await(read: Boolean, vararg values: Chapter): Result = withContext(NonCancellable) {
|
suspend fun await(read: Boolean, vararg chapters: Chapter): Result = withNonCancellableContext {
|
||||||
val chapters = values.filterNot { it.read == read }
|
val chaptersToUpdate = chapters.filterNot { it.read == read }
|
||||||
|
if (chaptersToUpdate.isEmpty()) {
|
||||||
if (chapters.isEmpty()) {
|
return@withNonCancellableContext Result.NoChapters
|
||||||
return@withContext Result.NoChapters
|
|
||||||
}
|
|
||||||
|
|
||||||
val manga = chapters.fold(mutableSetOf<Manga>()) { acc, chapter ->
|
|
||||||
if (acc.all { it.id != chapter.mangaId }) {
|
|
||||||
acc += mangaRepository.getMangaById(chapter.mangaId)
|
|
||||||
}
|
|
||||||
acc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
chapterRepository.updateAll(
|
chapterRepository.updateAll(
|
||||||
chapters.map { chapter ->
|
chaptersToUpdate.map { mapper(it, read) },
|
||||||
mapper(chapter, read)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logcat(LogPriority.ERROR, e)
|
logcat(LogPriority.ERROR, e)
|
||||||
return@withContext Result.InternalError(e)
|
return@withNonCancellableContext Result.InternalError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read && downloadPreferences.removeAfterMarkedAsRead().get()) {
|
if (read && downloadPreferences.removeAfterMarkedAsRead().get()) {
|
||||||
manga.forEach {
|
chaptersToUpdate
|
||||||
|
.groupBy { it.mangaId }
|
||||||
|
.forEach { (mangaId, chapters) ->
|
||||||
deleteDownload.awaitAll(
|
deleteDownload.awaitAll(
|
||||||
manga = it,
|
manga = mangaRepository.getMangaById(mangaId),
|
||||||
values = chapters
|
chapters = chapters.toTypedArray(),
|
||||||
.filter { chapter -> it.id == chapter.mangaId }
|
|
||||||
.toTypedArray(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,10 +55,10 @@ class SetReadStatus(
|
|||||||
Result.Success
|
Result.Success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun await(mangaId: Long, read: Boolean): Result = withContext(NonCancellable) {
|
suspend fun await(mangaId: Long, read: Boolean): Result = withNonCancellableContext {
|
||||||
await(
|
await(
|
||||||
read = read,
|
read = read,
|
||||||
values = chapterRepository
|
chapters = chapterRepository
|
||||||
.getChapterByMangaId(mangaId)
|
.getChapterByMangaId(mangaId)
|
||||||
.toTypedArray(),
|
.toTypedArray(),
|
||||||
)
|
)
|
||||||
|
@ -9,8 +9,8 @@ import eu.kanade.domain.chapter.repository.ChapterRepository
|
|||||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
|
import eu.kanade.tachiyomi.source.isLocal
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
||||||
@ -42,7 +42,7 @@ class SyncChaptersWithSource(
|
|||||||
manga: Manga,
|
manga: Manga,
|
||||||
source: Source,
|
source: Source,
|
||||||
): List<Chapter> {
|
): List<Chapter> {
|
||||||
if (rawSourceChapters.isEmpty() && source.id != LocalSource.ID) {
|
if (rawSourceChapters.isEmpty() && !source.isLocal()) {
|
||||||
throw NoChaptersException()
|
throw NoChaptersException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,17 +5,16 @@ import eu.kanade.domain.chapter.model.toDbChapter
|
|||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import kotlinx.coroutines.NonCancellable
|
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
|
|
||||||
class DeleteDownload(
|
class DeleteDownload(
|
||||||
private val sourceManager: SourceManager,
|
private val sourceManager: SourceManager,
|
||||||
private val downloadManager: DownloadManager,
|
private val downloadManager: DownloadManager,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun awaitAll(manga: Manga, vararg values: Chapter) = withContext(NonCancellable) {
|
suspend fun awaitAll(manga: Manga, vararg chapters: Chapter) = withNonCancellableContext {
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
downloadManager.deleteChapters(values.map { it.toDbChapter() }, manga, source)
|
downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package eu.kanade.domain.history.interactor
|
|||||||
|
|
||||||
import eu.kanade.domain.history.repository.HistoryRepository
|
import eu.kanade.domain.history.repository.HistoryRepository
|
||||||
|
|
||||||
class DeleteHistoryTable(
|
class DeleteAllHistory(
|
||||||
private val repository: HistoryRepository,
|
private val repository: HistoryRepository,
|
||||||
) {
|
) {
|
||||||
|
|
@ -20,8 +20,8 @@ class UpdateManga(
|
|||||||
return mangaRepository.update(mangaUpdate)
|
return mangaRepository.update(mangaUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun awaitAll(values: List<MangaUpdate>): Boolean {
|
suspend fun awaitAll(mangaUpdates: List<MangaUpdate>): Boolean {
|
||||||
return mangaRepository.updateAll(values)
|
return mangaRepository.updateAll(mangaUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun awaitUpdateFromSource(
|
suspend fun awaitUpdateFromSource(
|
||||||
|
@ -33,5 +33,5 @@ interface MangaRepository {
|
|||||||
|
|
||||||
suspend fun update(update: MangaUpdate): Boolean
|
suspend fun update(update: MangaUpdate): Boolean
|
||||||
|
|
||||||
suspend fun updateAll(values: List<MangaUpdate>): Boolean
|
suspend fun updateAll(mangaUpdates: List<MangaUpdate>): Boolean
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class GetUpdates(
|
|||||||
return repository.subscribeAll(after)
|
return repository.subscribeAll(after)
|
||||||
.onEach { updates ->
|
.onEach { updates ->
|
||||||
// Set unread chapter count for bottom bar badge
|
// Set unread chapter count for bottom bar badge
|
||||||
preferences.unreadUpdatesCount().set(updates.count { it.read.not() })
|
preferences.unreadUpdatesCount().set(updates.count { !it.read })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import eu.kanade.domain.category.model.Category
|
import eu.kanade.domain.category.model.Category
|
||||||
import eu.kanade.domain.library.model.display
|
import eu.kanade.domain.library.model.display
|
||||||
|
import eu.kanade.domain.manga.model.isLocal
|
||||||
import eu.kanade.presentation.components.EmptyScreen
|
import eu.kanade.presentation.components.EmptyScreen
|
||||||
import eu.kanade.presentation.components.EmptyScreenAction
|
import eu.kanade.presentation.components.EmptyScreenAction
|
||||||
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
||||||
@ -18,7 +19,6 @@ import eu.kanade.presentation.components.Scaffold
|
|||||||
import eu.kanade.presentation.library.components.LibraryContent
|
import eu.kanade.presentation.library.components.LibraryContent
|
||||||
import eu.kanade.presentation.library.components.LibraryToolbar
|
import eu.kanade.presentation.library.components.LibraryToolbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||||
import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView
|
import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ fun LibraryScreen(
|
|||||||
onChangeCategoryClicked = onChangeCategoryClicked,
|
onChangeCategoryClicked = onChangeCategoryClicked,
|
||||||
onMarkAsReadClicked = onMarkAsReadClicked,
|
onMarkAsReadClicked = onMarkAsReadClicked,
|
||||||
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
||||||
onDownloadClicked = onDownloadClicked.takeIf { presenter.selection.none { it.manga.source == LocalSource.ID } },
|
onDownloadClicked = onDownloadClicked.takeIf { presenter.selection.none { it.manga.isLocal() } },
|
||||||
onDeleteClicked = onDeleteClicked,
|
onDeleteClicked = onDeleteClicked,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -395,7 +395,7 @@ class Downloader(
|
|||||||
// When the page is ready, set page path, progress (just in case) and status
|
// When the page is ready, set page path, progress (just in case) and status
|
||||||
.doOnNext { file ->
|
.doOnNext { file ->
|
||||||
val success = splitTallImageIfNeeded(page, tmpDir)
|
val success = splitTallImageIfNeeded(page, tmpDir)
|
||||||
if (success.not()) {
|
if (!success) {
|
||||||
notifier.onError(context.getString(R.string.download_notifier_split_failed), download.chapter.name, download.manga.title)
|
notifier.onError(context.getString(R.string.download_notifier_split_failed), download.chapter.name, download.manga.title)
|
||||||
}
|
}
|
||||||
page.uri = file.uri
|
page.uri = file.uri
|
||||||
|
@ -28,4 +28,6 @@ fun Source.getNameForMangaInfo(): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Source.isLocalOrStub(): Boolean = id == LocalSource.ID || this is SourceManager.StubSource
|
fun Source.isLocal(): Boolean = id == LocalSource.ID
|
||||||
|
|
||||||
|
fun Source.isLocalOrStub(): Boolean = isLocal() || this is SourceManager.StubSource
|
||||||
|
@ -631,7 +631,7 @@ class MangaPresenter(
|
|||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
setReadStatus.await(
|
setReadStatus.await(
|
||||||
read = read,
|
read = read,
|
||||||
values = chapters.toTypedArray(),
|
chapters = chapters.toTypedArray(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
toggleAllSelection(false)
|
toggleAllSelection(false)
|
||||||
|
@ -9,7 +9,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import eu.kanade.core.util.insertSeparators
|
import eu.kanade.core.util.insertSeparators
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.domain.chapter.model.Chapter
|
import eu.kanade.domain.chapter.model.Chapter
|
||||||
import eu.kanade.domain.history.interactor.DeleteHistoryTable
|
import eu.kanade.domain.history.interactor.DeleteAllHistory
|
||||||
import eu.kanade.domain.history.interactor.GetHistory
|
import eu.kanade.domain.history.interactor.GetHistory
|
||||||
import eu.kanade.domain.history.interactor.GetNextChapter
|
import eu.kanade.domain.history.interactor.GetNextChapter
|
||||||
import eu.kanade.domain.history.interactor.RemoveHistoryById
|
import eu.kanade.domain.history.interactor.RemoveHistoryById
|
||||||
@ -38,7 +38,7 @@ class HistoryPresenter(
|
|||||||
private val state: HistoryStateImpl = HistoryState() as HistoryStateImpl,
|
private val state: HistoryStateImpl = HistoryState() as HistoryStateImpl,
|
||||||
private val getHistory: GetHistory = Injekt.get(),
|
private val getHistory: GetHistory = Injekt.get(),
|
||||||
private val getNextChapter: GetNextChapter = Injekt.get(),
|
private val getNextChapter: GetNextChapter = Injekt.get(),
|
||||||
private val deleteHistoryTable: DeleteHistoryTable = Injekt.get(),
|
private val deleteAllHistory: DeleteAllHistory = Injekt.get(),
|
||||||
private val removeHistoryById: RemoveHistoryById = Injekt.get(),
|
private val removeHistoryById: RemoveHistoryById = Injekt.get(),
|
||||||
private val removeHistoryByMangaId: RemoveHistoryByMangaId = Injekt.get(),
|
private val removeHistoryByMangaId: RemoveHistoryByMangaId = Injekt.get(),
|
||||||
preferences: BasePreferences = Injekt.get(),
|
preferences: BasePreferences = Injekt.get(),
|
||||||
@ -101,7 +101,7 @@ class HistoryPresenter(
|
|||||||
|
|
||||||
fun deleteAllHistory() {
|
fun deleteAllHistory() {
|
||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
val result = deleteHistoryTable.await()
|
val result = deleteAllHistory.await()
|
||||||
if (!result) return@launchIO
|
if (!result) return@launchIO
|
||||||
withUIContext {
|
withUIContext {
|
||||||
view?.activity?.toast(R.string.clear_history_completed)
|
view?.activity?.toast(R.string.clear_history_completed)
|
||||||
|
@ -215,7 +215,7 @@ class UpdatesPresenter(
|
|||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
setReadStatus.await(
|
setReadStatus.await(
|
||||||
read = read,
|
read = read,
|
||||||
values = updates
|
chapters = updates
|
||||||
.mapNotNull { getChapter.await(it.update.chapterId) }
|
.mapNotNull { getChapter.await(it.update.chapterId) }
|
||||||
.toTypedArray(),
|
.toTypedArray(),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user