mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
90% converted to GQL
This commit is contained in:
@@ -14,6 +14,8 @@ enum class RestoreState {
|
||||
FAILURE,
|
||||
RESTORING_CATEGORIES,
|
||||
RESTORING_MANGA,
|
||||
RESTORING_META,
|
||||
RESTORING_SETTINGS,
|
||||
UNKNOWN,
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
@@ -20,7 +20,7 @@ import org.lighthousegames.logging.logging
|
||||
class AddMangaToCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -49,7 +49,7 @@ class AddMangaToCategory
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
) = if (categoryId != 0L) {
|
||||
categoryRepositoryOld.addMangaToCategory(mangaId, categoryId)
|
||||
categoryRepository.addMangaToCategory(mangaId, categoryId)
|
||||
.map { serverListeners.updateCategoryManga(categoryId) }
|
||||
} else {
|
||||
flow {
|
||||
@@ -62,7 +62,7 @@ class AddMangaToCategory
|
||||
manga: Manga,
|
||||
category: Category,
|
||||
) = if (category.id != 0L) {
|
||||
categoryRepositoryOld.addMangaToCategory(manga.id, category.id)
|
||||
categoryRepository.addMangaToCategory(manga.id, category.id)
|
||||
.map { serverListeners.updateCategoryManga(category.id) }
|
||||
} else {
|
||||
flow {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class CreateCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
name: String,
|
||||
@@ -27,7 +27,7 @@ class CreateCategory
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(name: String) = categoryRepositoryOld.createCategory(name)
|
||||
fun asFlow(name: String) = categoryRepository.createCategory(name)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class DeleteCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
categoryId: Long,
|
||||
@@ -38,9 +38,9 @@ class DeleteCategory
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(categoryId: Long) = categoryRepositoryOld.deleteCategory(categoryId)
|
||||
fun asFlow(categoryId: Long) = categoryRepository.deleteCategory(categoryId)
|
||||
|
||||
fun asFlow(category: Category) = categoryRepositoryOld.deleteCategory(category.id)
|
||||
fun asFlow(category: Category) = categoryRepository.deleteCategory(category.id)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetCategories
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
dropDefault: Boolean = false,
|
||||
@@ -29,7 +29,7 @@ class GetCategories
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(dropDefault: Boolean = false) =
|
||||
categoryRepositoryOld.getCategories()
|
||||
categoryRepository.getCategories()
|
||||
.map { categories ->
|
||||
if (dropDefault) {
|
||||
categories.filterNot { it.name.equals("default", true) }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetMangaCategories
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
@@ -38,9 +38,9 @@ class GetMangaCategories
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) = categoryRepositoryOld.getMangaCategories(mangaId)
|
||||
fun asFlow(mangaId: Long) = categoryRepository.getMangaCategories(mangaId)
|
||||
|
||||
fun asFlow(manga: Manga) = categoryRepositoryOld.getMangaCategories(manga.id)
|
||||
fun asFlow(manga: Manga) = categoryRepository.getMangaCategories(manga.id)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import kotlinx.coroutines.flow.take
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetMangaListFromCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -45,12 +45,12 @@ class GetMangaListFromCategory
|
||||
|
||||
fun asFlow(categoryId: Long) =
|
||||
serverListeners.combineCategoryManga(
|
||||
categoryRepositoryOld.getMangaFromCategory(categoryId),
|
||||
categoryRepository.getMangaFromCategory(categoryId),
|
||||
) { categoryId == it }
|
||||
|
||||
fun asFlow(category: Category) =
|
||||
serverListeners.combineCategoryManga(
|
||||
categoryRepositoryOld.getMangaFromCategory(category.id),
|
||||
categoryRepository.getMangaFromCategory(category.id),
|
||||
) { category.id == it }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class ModifyCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
categoryId: Long,
|
||||
@@ -45,7 +45,7 @@ class ModifyCategory
|
||||
fun asFlow(
|
||||
categoryId: Long,
|
||||
name: String,
|
||||
) = categoryRepositoryOld.modifyCategory(
|
||||
) = categoryRepository.modifyCategory(
|
||||
categoryId = categoryId,
|
||||
name = name,
|
||||
)
|
||||
@@ -53,7 +53,7 @@ class ModifyCategory
|
||||
fun asFlow(
|
||||
category: Category,
|
||||
name: String? = null,
|
||||
) = categoryRepositoryOld.modifyCategory(
|
||||
) = categoryRepository.modifyCategory(
|
||||
categoryId = category.id,
|
||||
name = name ?: category.name,
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
@@ -20,7 +20,7 @@ import org.lighthousegames.logging.logging
|
||||
class RemoveMangaFromCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -49,7 +49,7 @@ class RemoveMangaFromCategory
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
) = if (categoryId != 0L) {
|
||||
categoryRepositoryOld.removeMangaFromCategory(mangaId, categoryId)
|
||||
categoryRepository.removeMangaFromCategory(mangaId, categoryId)
|
||||
.map { serverListeners.updateCategoryManga(categoryId) }
|
||||
} else {
|
||||
flow {
|
||||
@@ -62,7 +62,7 @@ class RemoveMangaFromCategory
|
||||
manga: Manga,
|
||||
category: Category,
|
||||
) = if (category.id != 0L) {
|
||||
categoryRepositoryOld.removeMangaFromCategory(manga.id, category.id)
|
||||
categoryRepository.removeMangaFromCategory(manga.id, category.id)
|
||||
.map { serverListeners.updateCategoryManga(category.id) }
|
||||
} else {
|
||||
flow {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,23 +15,23 @@ import org.lighthousegames.logging.logging
|
||||
class ReorderCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
to: Int,
|
||||
from: Int,
|
||||
categoryId: Long,
|
||||
position: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(to, from)
|
||||
) = asFlow(categoryId, position)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to move category from $from to $to" }
|
||||
log.warn(it) { "Failed to move category $categoryId to $position" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
to: Int,
|
||||
from: Int,
|
||||
) = categoryRepositoryOld.reorderCategory(to, from)
|
||||
categoryId: Long,
|
||||
position: Int,
|
||||
) = categoryRepository.reorderCategory(categoryId, position)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.category.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepositoryOld
|
||||
import ca.gosyer.jui.domain.category.service.CategoryRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateCategoryMeta
|
||||
@Inject
|
||||
constructor(
|
||||
private val categoryRepositoryOld: CategoryRepositoryOld,
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
category: Category,
|
||||
@@ -35,7 +35,7 @@ class UpdateCategoryMeta
|
||||
example: Int = category.meta.example,
|
||||
) = flow {
|
||||
if (example != category.meta.example) {
|
||||
categoryRepositoryOld.updateCategoryMeta(
|
||||
categoryRepository.updateCategoryMeta(
|
||||
category.id,
|
||||
"example",
|
||||
example.toString(),
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.category.service
|
||||
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface CategoryRepository {
|
||||
|
||||
fun getMangaCategories(
|
||||
mangaId: Long,
|
||||
): Flow<List<Category>>
|
||||
|
||||
fun addMangaToCategory(
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun removeMangaFromCategory(
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun getCategories(): Flow<List<Category>>
|
||||
|
||||
fun createCategory(
|
||||
name: String,
|
||||
): Flow<Unit>
|
||||
|
||||
fun modifyCategory(
|
||||
categoryId: Long,
|
||||
name: String,
|
||||
): Flow<Unit>
|
||||
|
||||
fun reorderCategory(
|
||||
categoryId: Long,
|
||||
position: Int,
|
||||
): Flow<Unit>
|
||||
|
||||
fun deleteCategory(
|
||||
categoryId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun getMangaFromCategory(
|
||||
categoryId: Long,
|
||||
): Flow<List<Manga>>
|
||||
|
||||
fun updateCategoryMeta(
|
||||
categoryId: Long,
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.download.model.DownloadEnqueue
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class BatchChapterDownload
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
chapterIds: List<Long>,
|
||||
@@ -38,9 +37,9 @@ class BatchChapterDownload
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(chapterIds: List<Long>) = downloadRepositoryOld.batchDownload(DownloadEnqueue(chapterIds))
|
||||
fun asFlow(chapterIds: List<Long>) = downloadRepository.batchDownload(chapterIds)
|
||||
|
||||
fun asFlow(vararg chapterIds: Long) = downloadRepositoryOld.batchDownload(DownloadEnqueue(chapterIds.asList()))
|
||||
fun asFlow(vararg chapterIds: Long) = downloadRepository.batchDownload(chapterIds.asList())
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class ClearDownloadQueue
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class ClearDownloadQueue
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow() = downloadRepositoryOld.clearDownloadQueue()
|
||||
fun asFlow() = downloadRepository.clearDownloadQueue()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.chapter.model.Chapter
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -17,51 +15,21 @@ import org.lighthousegames.logging.logging
|
||||
class QueueChapterDownload
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
chapterId: Long,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index)
|
||||
) = asFlow(chapterId)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to queue chapter $index of $mangaId for a download" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to queue chapter $index of ${manga.title}(${manga.id}) for a download" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to queue chapter ${chapter.index} of ${chapter.mangaId} for a download" }
|
||||
log.warn(it) { "Failed to queue chapter ${chapterId} for a download" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
) = downloadRepositoryOld.queueChapterDownload(mangaId, index)
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
) = downloadRepositoryOld.queueChapterDownload(manga.id, index)
|
||||
|
||||
fun asFlow(chapter: Chapter) = downloadRepositoryOld.queueChapterDownload(chapter.mangaId, chapter.index)
|
||||
chapterId: Long,
|
||||
) = downloadRepository.queueChapterDownload(chapterId)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.chapter.model.Chapter
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -17,59 +15,23 @@ import org.lighthousegames.logging.logging
|
||||
class ReorderChapterDownload
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
chapterId: Long,
|
||||
to: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index, to)
|
||||
) = asFlow(chapterId, to)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to reorder chapter download for $index of $mangaId to $to" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
to: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index, to)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to reorder chapter download for $index of ${manga.title}(${manga.id}) to $to" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
to: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, to)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to reorder chapter download for ${chapter.index} of ${chapter.mangaId} to $to" }
|
||||
log.warn(it) { "Failed to reorder chapter download for $chapterId to $to" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
chapterId: Long,
|
||||
to: Int,
|
||||
) = downloadRepositoryOld.reorderChapterDownload(mangaId, index, to)
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
to: Int,
|
||||
) = downloadRepositoryOld.reorderChapterDownload(manga.id, index, to)
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
to: Int,
|
||||
) = downloadRepositoryOld.reorderChapterDownload(chapter.mangaId, chapter.index, to)
|
||||
) = downloadRepository.reorderChapterDownload(chapterId, to)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class StartDownloading
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class StartDownloading
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow() = downloadRepositoryOld.startDownloading()
|
||||
fun asFlow() = downloadRepository.startDownloading()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.chapter.model.Chapter
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -17,51 +15,19 @@ import org.lighthousegames.logging.logging
|
||||
class StopChapterDownload
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
chapterId: Long,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index)
|
||||
) = asFlow(chapterId)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to stop chapter download for $index of $mangaId" }
|
||||
log.warn(it) { "Failed to stop chapter download for $chapterId" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to stop chapter download for $index of ${manga.title}(${manga.id})" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to stop chapter download for ${chapter.index} of ${chapter.mangaId}" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
) = downloadRepositoryOld.stopChapterDownload(mangaId, index)
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
) = downloadRepositoryOld.stopChapterDownload(manga.id, index)
|
||||
|
||||
fun asFlow(chapter: Chapter) = downloadRepositoryOld.stopChapterDownload(chapter.mangaId, chapter.index)
|
||||
fun asFlow(chapterId: Long) = downloadRepository.stopChapterDownload(chapterId)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.download.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepositoryOld
|
||||
import ca.gosyer.jui.domain.download.service.DownloadRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class StopDownloading
|
||||
@Inject
|
||||
constructor(
|
||||
private val downloadRepositoryOld: DownloadRepositoryOld,
|
||||
private val downloadRepository: DownloadRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class StopDownloading
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow() = downloadRepositoryOld.stopDownloading()
|
||||
fun asFlow() = downloadRepository.stopDownloading()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.download.service
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface DownloadRepository {
|
||||
|
||||
fun startDownloading(): Flow<Unit>
|
||||
|
||||
fun stopDownloading(): Flow<Unit>
|
||||
|
||||
fun clearDownloadQueue(): Flow<Unit>
|
||||
|
||||
fun queueChapterDownload(
|
||||
chapterId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun stopChapterDownload(
|
||||
chapterId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun reorderChapterDownload(
|
||||
chapterId: Long,
|
||||
to: Int,
|
||||
): Flow<Unit>
|
||||
|
||||
fun batchDownload(
|
||||
chapterIds: List<Long>,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.extension.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepositoryOld
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetExtensionList
|
||||
@Inject
|
||||
constructor(
|
||||
private val extensionRepositoryOld: ExtensionRepositoryOld,
|
||||
private val extensionRepository: ExtensionRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class GetExtensionList
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow() = extensionRepositoryOld.getExtensionList()
|
||||
fun asFlow() = extensionRepository.getExtensionList()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.extension.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.extension.model.Extension
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepositoryOld
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class InstallExtension
|
||||
@Inject
|
||||
constructor(
|
||||
private val extensionRepositoryOld: ExtensionRepositoryOld,
|
||||
private val extensionRepository: ExtensionRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
extension: Extension,
|
||||
@@ -28,7 +28,7 @@ class InstallExtension
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(extension: Extension) = extensionRepositoryOld.installExtension(extension.pkgName)
|
||||
fun asFlow(extension: Extension) = extensionRepository.installExtension(extension.pkgName)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,17 +6,19 @@
|
||||
|
||||
package ca.gosyer.jui.domain.extension.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepositoryOld
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import okio.FileSystem
|
||||
import okio.Path
|
||||
import okio.SYSTEM
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
class InstallExtensionFile
|
||||
@Inject
|
||||
constructor(
|
||||
private val extensionRepositoryOld: ExtensionRepositoryOld,
|
||||
private val extensionRepository: ExtensionRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
path: Path,
|
||||
@@ -28,7 +30,7 @@ class InstallExtensionFile
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(path: Path) = extensionRepositoryOld.installExtension(ExtensionRepositoryOld.buildExtensionFormData(path))
|
||||
fun asFlow(path: Path) = extensionRepository.installExtension(FileSystem.SYSTEM.source(path))
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.extension.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.extension.model.Extension
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepositoryOld
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class UninstallExtension
|
||||
@Inject
|
||||
constructor(
|
||||
private val extensionRepositoryOld: ExtensionRepositoryOld,
|
||||
private val extensionRepository: ExtensionRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
extension: Extension,
|
||||
@@ -28,7 +28,7 @@ class UninstallExtension
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(extension: Extension) = extensionRepositoryOld.uninstallExtension(extension.pkgName)
|
||||
fun asFlow(extension: Extension) = extensionRepository.uninstallExtension(extension.pkgName)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.extension.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.extension.model.Extension
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepositoryOld
|
||||
import ca.gosyer.jui.domain.extension.service.ExtensionRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateExtension
|
||||
@Inject
|
||||
constructor(
|
||||
private val extensionRepositoryOld: ExtensionRepositoryOld,
|
||||
private val extensionRepository: ExtensionRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
extension: Extension,
|
||||
@@ -28,7 +28,7 @@ class UpdateExtension
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(extension: Extension) = extensionRepositoryOld.updateExtension(extension.pkgName)
|
||||
fun asFlow(extension: Extension) = extensionRepository.updateExtension(extension.pkgName)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.extension.service
|
||||
|
||||
import ca.gosyer.jui.domain.extension.model.Extension
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import okio.Source
|
||||
|
||||
interface ExtensionRepository {
|
||||
|
||||
fun getExtensionList(): Flow<List<Extension>>
|
||||
|
||||
fun installExtension(
|
||||
source: Source,
|
||||
): Flow<Unit>
|
||||
|
||||
fun installExtension(
|
||||
pkgName: String,
|
||||
): Flow<Unit>
|
||||
|
||||
fun updateExtension(
|
||||
pkgName: String,
|
||||
): Flow<Unit>
|
||||
|
||||
fun uninstallExtension(
|
||||
pkgName: String,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.global.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.global.service.GlobalRepositoryOld
|
||||
import ca.gosyer.jui.domain.global.service.GlobalRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetGlobalMeta
|
||||
@Inject
|
||||
constructor(
|
||||
private val globalRepositoryOld: GlobalRepositoryOld,
|
||||
private val globalRepository: GlobalRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class GetGlobalMeta
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow() = globalRepositoryOld.getGlobalMeta()
|
||||
fun asFlow() = globalRepository.getGlobalMeta()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.global.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.global.model.GlobalMeta
|
||||
import ca.gosyer.jui.domain.global.service.GlobalRepositoryOld
|
||||
import ca.gosyer.jui.domain.global.service.GlobalRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateGlobalMeta
|
||||
@Inject
|
||||
constructor(
|
||||
private val globalRepositoryOld: GlobalRepositoryOld,
|
||||
private val globalRepository: GlobalRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
globalMeta: GlobalMeta,
|
||||
@@ -35,7 +35,7 @@ class UpdateGlobalMeta
|
||||
example: Int = globalMeta.example,
|
||||
) = flow {
|
||||
if (example != globalMeta.example) {
|
||||
globalRepositoryOld.updateGlobalMeta(
|
||||
globalRepository.updateGlobalMeta(
|
||||
"example",
|
||||
example.toString(),
|
||||
).collect()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.global.service
|
||||
|
||||
import ca.gosyer.jui.domain.global.model.GlobalMeta
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface GlobalRepository {
|
||||
fun getGlobalMeta(): Flow<GlobalMeta>
|
||||
|
||||
fun updateGlobalMeta(
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.library.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.library.service.LibraryRepositoryOld
|
||||
import ca.gosyer.jui.domain.library.service.LibraryRepository
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
class AddMangaToLibrary
|
||||
@Inject
|
||||
constructor(
|
||||
private val libraryRepositoryOld: LibraryRepositoryOld,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -42,11 +42,11 @@ class AddMangaToLibrary
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) =
|
||||
libraryRepositoryOld.addMangaToLibrary(mangaId)
|
||||
libraryRepository.addMangaToLibrary(mangaId)
|
||||
.onEach { serverListeners.updateManga(mangaId) }
|
||||
|
||||
fun asFlow(manga: Manga) =
|
||||
libraryRepositoryOld.addMangaToLibrary(manga.id)
|
||||
libraryRepository.addMangaToLibrary(manga.id)
|
||||
.onEach { serverListeners.updateManga(manga.id) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.library.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.library.service.LibraryRepositoryOld
|
||||
import ca.gosyer.jui.domain.library.service.LibraryRepository
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
class RemoveMangaFromLibrary
|
||||
@Inject
|
||||
constructor(
|
||||
private val libraryRepositoryOld: LibraryRepositoryOld,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -42,11 +42,11 @@ class RemoveMangaFromLibrary
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) =
|
||||
libraryRepositoryOld.removeMangaFromLibrary(mangaId)
|
||||
libraryRepository.removeMangaFromLibrary(mangaId)
|
||||
.onEach { serverListeners.updateManga(mangaId) }
|
||||
|
||||
fun asFlow(manga: Manga) =
|
||||
libraryRepositoryOld.removeMangaFromLibrary(manga.id)
|
||||
libraryRepository.removeMangaFromLibrary(manga.id)
|
||||
.onEach { serverListeners.updateManga(manga.id) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.library.service
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface LibraryRepository {
|
||||
fun addMangaToLibrary(
|
||||
mangaId: Long,
|
||||
): Flow<Unit>
|
||||
|
||||
fun removeMangaFromLibrary(
|
||||
mangaId: Long,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.manga.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import kotlinx.coroutines.flow.take
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val mangaRepositoryOld: MangaRepositoryOld,
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -45,12 +45,12 @@ class GetManga
|
||||
|
||||
fun asFlow(mangaId: Long) =
|
||||
serverListeners.combineMangaUpdates(
|
||||
mangaRepositoryOld.getManga(mangaId),
|
||||
mangaRepository.getManga(mangaId),
|
||||
) { mangaId in it }
|
||||
|
||||
fun asFlow(manga: Manga) =
|
||||
serverListeners.combineMangaUpdates(
|
||||
mangaRepositoryOld.getManga(manga.id),
|
||||
mangaRepository.getManga(manga.id),
|
||||
) { manga.id in it }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.manga.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepositoryOld
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import kotlinx.coroutines.flow.take
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
class GetMangaFull
|
||||
@Inject
|
||||
constructor(
|
||||
private val mangaRepositoryOld: MangaRepositoryOld,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId)
|
||||
.take(1)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get full manga $mangaId" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga)
|
||||
.take(1)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get full manga ${manga.title}(${manga.id})" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) =
|
||||
serverListeners.combineMangaUpdates(
|
||||
mangaRepositoryOld.getMangaFull(mangaId),
|
||||
) { mangaId in it }
|
||||
|
||||
fun asFlow(manga: Manga) =
|
||||
serverListeners.combineMangaUpdates(
|
||||
mangaRepositoryOld.getMangaFull(manga.id),
|
||||
) { manga.id in it }
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.manga.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
@@ -19,7 +19,7 @@ import org.lighthousegames.logging.logging
|
||||
class RefreshManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val mangaRepositoryOld: MangaRepositoryOld,
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -44,9 +44,9 @@ class RefreshManga
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) = mangaRepositoryOld.getManga(mangaId, true).onEach { serverListeners.updateManga(mangaId) }
|
||||
fun asFlow(mangaId: Long) = mangaRepository.refreshManga(mangaId).onEach { serverListeners.updateManga(mangaId) }
|
||||
|
||||
fun asFlow(manga: Manga) = mangaRepositoryOld.getManga(manga.id, true).onEach { serverListeners.updateManga(manga.id) }
|
||||
fun asFlow(manga: Manga) = mangaRepository.refreshManga(manga.id).onEach { serverListeners.updateManga(manga.id) }
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.manga.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepositoryOld
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import kotlinx.coroutines.flow.take
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
class RefreshMangaFull
|
||||
@Inject
|
||||
constructor(
|
||||
private val mangaRepositoryOld: MangaRepositoryOld,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId)
|
||||
.take(1)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to refresh full manga $mangaId" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga)
|
||||
.take(1)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to refresh full manga ${manga.title}(${manga.id})" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) = mangaRepositoryOld.getMangaFull(mangaId, true).onEach { serverListeners.updateManga(mangaId) }
|
||||
|
||||
fun asFlow(manga: Manga) = mangaRepositoryOld.getMangaFull(manga.id, true).onEach { serverListeners.updateManga(manga.id) }
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package ca.gosyer.jui.domain.manga.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.ServerListeners
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepositoryOld
|
||||
import ca.gosyer.jui.domain.manga.service.MangaRepository
|
||||
import io.ktor.http.decodeURLQueryComponent
|
||||
import io.ktor.http.encodeURLQueryComponent
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -20,7 +20,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateMangaMeta
|
||||
@Inject
|
||||
constructor(
|
||||
private val mangaRepositoryOld: MangaRepositoryOld,
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
suspend fun await(
|
||||
@@ -39,7 +39,7 @@ class UpdateMangaMeta
|
||||
readerMode: String = manga.meta.juiReaderMode.decodeURLQueryComponent(),
|
||||
) = flow {
|
||||
if (readerMode.encodeURLQueryComponent() != manga.meta.juiReaderMode) {
|
||||
mangaRepositoryOld.updateMangaMeta(
|
||||
mangaRepository.updateMangaMeta(
|
||||
manga.id,
|
||||
"juiReaderMode",
|
||||
readerMode,
|
||||
|
||||
@@ -8,7 +8,6 @@ package ca.gosyer.jui.domain.manga.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.Stable
|
||||
import ca.gosyer.jui.domain.chapter.model.Chapter
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.i18n.MR
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
@@ -42,7 +41,7 @@ data class Manga(
|
||||
val unreadCount: Int?,
|
||||
val downloadCount: Int?,
|
||||
val chapterCount: Int?,
|
||||
val lastChapterRead: Chapter? = null,
|
||||
val lastChapterReadTime: Long? = null,
|
||||
val age: Long?,
|
||||
val chaptersAge: Long?,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.manga.service
|
||||
|
||||
import ca.gosyer.jui.domain.manga.model.Manga
|
||||
import io.ktor.client.request.HttpRequestBuilder
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface MangaRepository {
|
||||
|
||||
fun getManga(
|
||||
mangaId: Long,
|
||||
): Flow<Manga>
|
||||
|
||||
fun refreshManga(
|
||||
mangaId: Long,
|
||||
): Flow<Manga>
|
||||
|
||||
fun getMangaLibrary(
|
||||
mangaId: Long,
|
||||
): Flow<Manga>
|
||||
|
||||
fun getMangaThumbnail(
|
||||
mangaId: Long,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<ByteReadChannel>
|
||||
|
||||
fun updateMangaMeta(
|
||||
mangaId: Long,
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
enum class AuthMode {
|
||||
NONE,
|
||||
BASIC_AUTH,
|
||||
SIMPLE_LOGIN,
|
||||
UI_LOGIN,
|
||||
UNKNOWN__,
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
enum class DatabaseType {
|
||||
H2,
|
||||
POSTGRESQL,
|
||||
UNKNOWN__,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
class DownloadConversion(
|
||||
val compressionLevel: Double?,
|
||||
val mimeType: String,
|
||||
val target: String,
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
enum class KoreaderSyncChecksumMethod {
|
||||
BINARY,
|
||||
FILENAME,
|
||||
UNKNOWN__,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
enum class KoreaderSyncConflictStrategy {
|
||||
PROMPT,
|
||||
KEEP_LOCAL,
|
||||
KEEP_REMOTE,
|
||||
DISABLED,
|
||||
UNKNOWN__,
|
||||
}
|
||||
@@ -7,17 +7,23 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
class SetSettingsInput(
|
||||
val authMode: AuthMode? = null,
|
||||
val authPassword: String? = null,
|
||||
val authUsername: String? = null,
|
||||
val autoDownloadIgnoreReUploads: Boolean? = null,
|
||||
val autoDownloadNewChapters: Boolean? = null,
|
||||
val autoDownloadNewChaptersLimit: Int? = null,
|
||||
val backupInterval: Int? = null,
|
||||
val backupPath: String? = null,
|
||||
val backupTTL: Int? = null,
|
||||
val backupTime: String? = null,
|
||||
val basicAuthEnabled: Boolean? = null,
|
||||
val basicAuthPassword: String? = null,
|
||||
val basicAuthUsername: String? = null,
|
||||
val databasePassword: String? = null,
|
||||
val databaseType: DatabaseType? = null,
|
||||
val databaseUrl: String? = null,
|
||||
val databaseUsername: String? = null,
|
||||
val debugLogsEnabled: Boolean? = null,
|
||||
val downloadAsCbz: Boolean? = null,
|
||||
val downloadConversions: List<DownloadConversion>? = null,
|
||||
val downloadsPath: String? = null,
|
||||
val electronPath: String? = null,
|
||||
val excludeCompleted: Boolean? = null,
|
||||
@@ -25,17 +31,38 @@ class SetSettingsInput(
|
||||
val excludeNotStarted: Boolean? = null,
|
||||
val excludeUnreadChapters: Boolean? = null,
|
||||
val extensionRepos: List<String>? = null,
|
||||
val flareSolverrAsResponseFallback: Boolean? = null,
|
||||
val flareSolverrEnabled: Boolean? = null,
|
||||
val flareSolverrSessionName: String? = null,
|
||||
val flareSolverrSessionTtl: Int? = null,
|
||||
val flareSolverrTimeout: Int? = null,
|
||||
val flareSolverrUrl: String? = null,
|
||||
val globalUpdateInterval: Double? = null,
|
||||
val gqlDebugLogsEnabled: Boolean? = null,
|
||||
val initialOpenInBrowserEnabled: Boolean? = null,
|
||||
val ip: String? = null,
|
||||
val jwtAudience: String? = null,
|
||||
val jwtRefreshExpiry: Any? = null,
|
||||
val jwtTokenExpiry: Any? = null,
|
||||
val koreaderSyncChecksumMethod: KoreaderSyncChecksumMethod? = null,
|
||||
val koreaderSyncDeviceId: String? = null,
|
||||
val koreaderSyncPercentageTolerance: Double? = null,
|
||||
val koreaderSyncServerUrl: String? = null,
|
||||
val koreaderSyncStrategyBackward: KoreaderSyncConflictStrategy? = null,
|
||||
val koreaderSyncStrategyForward: KoreaderSyncConflictStrategy? = null,
|
||||
val koreaderSyncUserkey: String? = null,
|
||||
val koreaderSyncUsername: String? = null,
|
||||
val localSourcePath: String? = null,
|
||||
val maxLogFileSize: String? = null,
|
||||
val maxLogFiles: Int? = null,
|
||||
val maxLogFolderSize: String? = null,
|
||||
val maxSourcesInParallel: Int? = null,
|
||||
val opdsChapterSortOrder: SortOrder? = null,
|
||||
val opdsEnablePageReadProgress: Boolean? = null,
|
||||
val opdsItemsPerPage: Int? = null,
|
||||
val opdsMarkAsReadOnDownload: Boolean? = null,
|
||||
val opdsShowOnlyDownloadedChapters: Boolean? = null,
|
||||
val opdsShowOnlyUnreadChapters: Boolean? = null,
|
||||
val opdsUseBinaryFileSizes: Boolean? = null,
|
||||
val port: Int? = null,
|
||||
val socksProxyEnabled: Boolean? = null,
|
||||
val socksProxyHost: String? = null,
|
||||
|
||||
@@ -10,17 +10,23 @@ import androidx.compose.runtime.Stable
|
||||
|
||||
@Stable
|
||||
class Settings(
|
||||
val authMode: AuthMode,
|
||||
val authPassword: String,
|
||||
val authUsername: String,
|
||||
val autoDownloadIgnoreReUploads: Boolean,
|
||||
val autoDownloadNewChapters: Boolean,
|
||||
val autoDownloadNewChaptersLimit: Int,
|
||||
val backupInterval: Int,
|
||||
val backupPath: String,
|
||||
val backupTTL: Int,
|
||||
val backupTime: String,
|
||||
val basicAuthEnabled: Boolean,
|
||||
val basicAuthPassword: String,
|
||||
val basicAuthUsername: String,
|
||||
val databasePassword: String,
|
||||
val databaseType: DatabaseType,
|
||||
val databaseUrl: String,
|
||||
val databaseUsername: String,
|
||||
val debugLogsEnabled: Boolean,
|
||||
val downloadAsCbz: Boolean,
|
||||
val downloadConversions: List<DownloadConversion>,
|
||||
val downloadsPath: String,
|
||||
val electronPath: String,
|
||||
val excludeCompleted: Boolean,
|
||||
@@ -28,17 +34,38 @@ class Settings(
|
||||
val excludeNotStarted: Boolean,
|
||||
val excludeUnreadChapters: Boolean,
|
||||
val extensionRepos: List<String>,
|
||||
val flareSolverrAsResponseFallback: Boolean,
|
||||
val flareSolverrEnabled: Boolean,
|
||||
val flareSolverrSessionName: String,
|
||||
val flareSolverrSessionTtl: Int,
|
||||
val flareSolverrTimeout: Int,
|
||||
val flareSolverrUrl: String,
|
||||
val globalUpdateInterval: Double,
|
||||
val gqlDebugLogsEnabled: Boolean,
|
||||
val initialOpenInBrowserEnabled: Boolean,
|
||||
val ip: String,
|
||||
val jwtAudience: String,
|
||||
val jwtRefreshExpiry: Any,
|
||||
val jwtTokenExpiry: Any,
|
||||
val koreaderSyncChecksumMethod: KoreaderSyncChecksumMethod,
|
||||
val koreaderSyncDeviceId: String,
|
||||
val koreaderSyncPercentageTolerance: Double,
|
||||
val koreaderSyncServerUrl: String,
|
||||
val koreaderSyncStrategyBackward: KoreaderSyncConflictStrategy,
|
||||
val koreaderSyncStrategyForward: KoreaderSyncConflictStrategy,
|
||||
val koreaderSyncUserkey: String,
|
||||
val koreaderSyncUsername: String,
|
||||
val localSourcePath: String,
|
||||
val maxLogFileSize: String,
|
||||
val maxLogFiles: Int,
|
||||
val maxLogFolderSize: String,
|
||||
val maxSourcesInParallel: Int,
|
||||
val opdsChapterSortOrder: SortOrder,
|
||||
val opdsEnablePageReadProgress: Boolean,
|
||||
val opdsItemsPerPage: Int,
|
||||
val opdsMarkAsReadOnDownload: Boolean,
|
||||
val opdsShowOnlyDownloadedChapters: Boolean,
|
||||
val opdsShowOnlyUnreadChapters: Boolean,
|
||||
val opdsUseBinaryFileSizes: Boolean,
|
||||
val port: Int,
|
||||
val socksProxyEnabled: Boolean,
|
||||
val socksProxyHost: String,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package ca.gosyer.jui.domain.settings.model
|
||||
|
||||
enum class SortOrder {
|
||||
ASC,
|
||||
DESC,
|
||||
ASC_NULLS_FIRST,
|
||||
DESC_NULLS_FIRST,
|
||||
ASC_NULLS_LAST,
|
||||
DESC_NULLS_LAST,
|
||||
UNKNOWN__,
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,39 +16,35 @@ import org.lighthousegames.logging.logging
|
||||
class GetFilterList
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
reset: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(source.id, reset)
|
||||
) = asFlow(source.id)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get filter list for ${source.displayName} with reset = $reset" }
|
||||
log.warn(it) { "Failed to get filter list for ${source.displayName}" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
suspend fun await(
|
||||
sourceId: Long,
|
||||
reset: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(sourceId, reset)
|
||||
) = asFlow(sourceId)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get filter list for $sourceId with reset = $reset" }
|
||||
log.warn(it) { "Failed to get filter list for $sourceId" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
reset: Boolean,
|
||||
) = sourceRepositoryOld.getFilterList(source.id, reset)
|
||||
) = sourceRepository.getFilterList(source.id)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
reset: Boolean,
|
||||
) = sourceRepositoryOld.getFilterList(sourceId, reset)
|
||||
) = sourceRepository.getFilterList(sourceId)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetLatestManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
@@ -43,12 +43,12 @@ class GetLatestManga
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getLatestManga(source.id, page)
|
||||
) = sourceRepository.getLatestManga(source.id, page)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getLatestManga(sourceId, page)
|
||||
) = sourceRepository.getLatestManga(sourceId, page)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetPopularManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
@@ -43,12 +43,12 @@ class GetPopularManga
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getPopularManga(source.id, page)
|
||||
) = sourceRepository.getPopularManga(source.id, page)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getPopularManga(sourceId, page)
|
||||
) = sourceRepository.getPopularManga(sourceId, page)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterChange
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterData
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
class GetQuickSearchManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
filters: List<SourceFilterChange>?,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(source.id, searchTerm, page, filters)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get quick search results from ${source.displayName} on page $page with query '$searchTerm'" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
suspend fun await(
|
||||
sourceId: Long,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
filters: List<SourceFilterChange>?,
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(sourceId, searchTerm, page, filters)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get quick search results from $sourceId on page $page with query '$searchTerm'" }
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
filters: List<SourceFilterChange>?,
|
||||
) = sourceRepositoryOld.getQuickSearchResults(
|
||||
source.id,
|
||||
page,
|
||||
SourceFilterData(
|
||||
searchTerm?.ifBlank { null },
|
||||
filters?.ifEmpty { null },
|
||||
),
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
filters: List<SourceFilterChange>?,
|
||||
) = sourceRepositoryOld.getQuickSearchResults(
|
||||
sourceId,
|
||||
page,
|
||||
SourceFilterData(
|
||||
searchTerm?.ifBlank { null },
|
||||
filters?.ifEmpty { null },
|
||||
),
|
||||
)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,8 @@
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilter
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,15 +17,16 @@ import org.lighthousegames.logging.logging
|
||||
class GetSearchManga
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
searchTerm: String?,
|
||||
filters: List<SourceFilter>?,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(source.id, searchTerm, page)
|
||||
) = asFlow(source.id, page, searchTerm, filters)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get search results from ${source.displayName} on page $page with query '$searchTerm'" }
|
||||
@@ -35,9 +37,10 @@ class GetSearchManga
|
||||
sourceId: Long,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
filters: List<SourceFilter>?,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(sourceId, searchTerm, page)
|
||||
) = asFlow(sourceId, page, searchTerm, filters)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to get search results from $sourceId on page $page with query '$searchTerm'" }
|
||||
@@ -46,22 +49,26 @@ class GetSearchManga
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getSearchResults(
|
||||
searchTerm: String?,
|
||||
filters: List<SourceFilter>?,
|
||||
) = sourceRepository.getSearchResults(
|
||||
source.id,
|
||||
searchTerm?.ifBlank { null },
|
||||
page,
|
||||
searchTerm?.ifBlank { null },
|
||||
filters,
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
searchTerm: String?,
|
||||
page: Int,
|
||||
) = sourceRepositoryOld.getSearchResults(
|
||||
searchTerm: String?,
|
||||
filters: List<SourceFilter>?,
|
||||
) = sourceRepository.getSearchResults(
|
||||
sourceId,
|
||||
searchTerm?.ifBlank { null },
|
||||
page,
|
||||
searchTerm?.ifBlank { null },
|
||||
filters,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetSourceList
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class GetSourceList
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow() = sourceRepositoryOld.getSourceList()
|
||||
fun asFlow() = sourceRepository.getSourceList()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetSourceSettings
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
@@ -38,9 +38,9 @@ class GetSourceSettings
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(source: Source) = sourceRepositoryOld.getSourceSettings(source.id)
|
||||
fun asFlow(source: Source) = sourceRepository.getSourceSettings(source.id)
|
||||
|
||||
fun asFlow(sourceId: Long) = sourceRepositoryOld.getSourceSettings(sourceId)
|
||||
fun asFlow(sourceId: Long) = sourceRepository.getSourceSettings(sourceId)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterChange
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
class SetSourceFilter
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
filterIndex: Int,
|
||||
filter: Any,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(source, filterIndex, filter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to set filter for ${source.displayName} with index = $filterIndex and value = $filter" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
sourceId: Long,
|
||||
filterIndex: Int,
|
||||
filter: Any,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(sourceId, filterIndex, filter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to set filter for $sourceId with index = $filterIndex and value = $filter" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
filterIndex: Int,
|
||||
childFilterIndex: Int,
|
||||
filter: Any,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(source, filterIndex, childFilterIndex, filter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) {
|
||||
"Failed to set filter for ${source.displayName} with index = $filterIndex " +
|
||||
"and childIndex = $childFilterIndex and value = $filter"
|
||||
}
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
sourceId: Long,
|
||||
filterIndex: Int,
|
||||
childFilterIndex: Int,
|
||||
filter: Any,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(sourceId, filterIndex, childFilterIndex, filter)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) {
|
||||
"Failed to set filter for $sourceId with index = $filterIndex " +
|
||||
"and childIndex = $childFilterIndex and value = $filter"
|
||||
}
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
filterIndex: Int,
|
||||
filter: Any,
|
||||
) = sourceRepositoryOld.setFilter(
|
||||
source.id,
|
||||
SourceFilterChange(filterIndex, filter),
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
filterIndex: Int,
|
||||
filter: Any,
|
||||
) = sourceRepositoryOld.setFilter(
|
||||
sourceId,
|
||||
SourceFilterChange(filterIndex, filter),
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
filterIndex: Int,
|
||||
childFilterIndex: Int,
|
||||
filter: Any,
|
||||
) = sourceRepositoryOld.setFilter(
|
||||
source.id,
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter))),
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
filterIndex: Int,
|
||||
childFilterIndex: Int,
|
||||
filter: Any,
|
||||
) = sourceRepositoryOld.setFilter(
|
||||
sourceId,
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter))),
|
||||
)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
package ca.gosyer.jui.domain.source.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreferenceChange
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepositoryOld
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreference
|
||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -17,50 +16,26 @@ import org.lighthousegames.logging.logging
|
||||
class SetSourceSetting
|
||||
@Inject
|
||||
constructor(
|
||||
private val sourceRepositoryOld: SourceRepositoryOld,
|
||||
private val sourceRepository: SourceRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
source: Source,
|
||||
settingIndex: Int,
|
||||
setting: Any,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(source, settingIndex, setting)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to set setting for ${source.displayName} with index = $settingIndex and value = $setting" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
suspend fun await(
|
||||
sourceId: Long,
|
||||
settingIndex: Int,
|
||||
setting: Any,
|
||||
sourcePreference: SourcePreference,
|
||||
onError: suspend (Throwable) -> Unit = {
|
||||
},
|
||||
) = asFlow(sourceId, settingIndex, setting)
|
||||
) = asFlow(sourceId, sourcePreference)
|
||||
.catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to set setting for $sourceId with index = $settingIndex and value = $setting" }
|
||||
log.warn(it) { "Failed to set setting for $sourceId with index = ${sourcePreference.position}" }
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(
|
||||
source: Source,
|
||||
settingIndex: Int,
|
||||
setting: Any,
|
||||
) = sourceRepositoryOld.setSourceSetting(
|
||||
source.id,
|
||||
SourcePreferenceChange(settingIndex, setting),
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
sourceId: Long,
|
||||
settingIndex: Int,
|
||||
setting: Any,
|
||||
) = sourceRepositoryOld.setSourceSetting(
|
||||
sourcePreference: SourcePreference,
|
||||
) = sourceRepository.setSourceSetting(
|
||||
sourceId,
|
||||
SourcePreferenceChange(settingIndex, setting),
|
||||
sourcePreference,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -11,9 +11,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("CheckBox")
|
||||
data class CheckBoxFilter(
|
||||
data class CheckBoxFilterOld(
|
||||
override val filter: CheckBoxProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class CheckBoxProps(
|
||||
override val name: String,
|
||||
@@ -11,12 +11,12 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("Group")
|
||||
data class GroupFilter(
|
||||
data class GroupFilterOld(
|
||||
override val filter: GroupProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class GroupProps(
|
||||
override val name: String,
|
||||
override val state: List<SourceFilter>,
|
||||
) : Props<List<SourceFilter>>
|
||||
override val state: List<SourceFilterOld>,
|
||||
) : Props<List<SourceFilterOld>>
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
@SerialName("Header")
|
||||
data class HeaderFilter(
|
||||
data class HeaderFilterOld(
|
||||
override val filter: HeaderProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class HeaderProps(
|
||||
override val name: String,
|
||||
@@ -12,9 +12,9 @@ import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@Serializable
|
||||
@SerialName("Select")
|
||||
data class SelectFilter(
|
||||
data class SelectFilterOld(
|
||||
override val filter: SelectProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class SelectProps(
|
||||
override val name: String,
|
||||
@@ -12,9 +12,9 @@ import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
@SerialName("Separator")
|
||||
data class SeparatorFilter(
|
||||
data class SeparatorFilterOld(
|
||||
override val filter: SeparatorProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class SeparatorProps(
|
||||
override val name: String,
|
||||
@@ -11,9 +11,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("Sort")
|
||||
data class SortFilter(
|
||||
data class SortFilterOld(
|
||||
override val filter: SortProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class SortProps(
|
||||
override val name: String,
|
||||
@@ -11,16 +11,84 @@ import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Serializable
|
||||
data class SourceFilterChange(
|
||||
data class SourceFilterChangeOld(
|
||||
val position: Int,
|
||||
val state: String,
|
||||
) {
|
||||
constructor(position: Int, state: Any) : this(
|
||||
position,
|
||||
if (state is SortFilter.Selection) {
|
||||
if (state is SortFilterOld.Selection) {
|
||||
Json.encodeToString(state)
|
||||
} else {
|
||||
state.toString()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
sealed interface SourceFilter {
|
||||
val position: Int
|
||||
data class Checkbox(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val default: Boolean,
|
||||
val value: Boolean = default,
|
||||
): SourceFilter
|
||||
|
||||
data class Header(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
): SourceFilter
|
||||
|
||||
data class Separator(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
): SourceFilter
|
||||
|
||||
data class Group(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val value: List<SourceFilter>,
|
||||
): SourceFilter
|
||||
|
||||
data class Select(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val values: List<String>,
|
||||
val default: Int,
|
||||
val value: Int = default,
|
||||
): SourceFilter
|
||||
|
||||
data class Sort(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val values: List<String>,
|
||||
val default: SelectionChange?,
|
||||
val value: SelectionChange? = default,
|
||||
): SourceFilter {
|
||||
data class SelectionChange(
|
||||
val ascending: Boolean,
|
||||
val index: Int
|
||||
)
|
||||
}
|
||||
|
||||
data class Text(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val default: String,
|
||||
val value: String = default,
|
||||
): SourceFilter
|
||||
|
||||
data class TriState(
|
||||
override val position: Int,
|
||||
val name: String,
|
||||
val default: TriStateValue,
|
||||
val value: TriStateValue = default,
|
||||
): SourceFilter {
|
||||
enum class TriStateValue {
|
||||
IGNORE,
|
||||
INCLUDE,
|
||||
EXCLUDE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class SourceFilterData(
|
||||
val searchTerm: String?,
|
||||
val filter: List<SourceFilterChange>?,
|
||||
val filter: List<SourceFilterChangeOld>?,
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ package ca.gosyer.jui.domain.source.model.sourcefilters
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class SourceFilter {
|
||||
sealed class SourceFilterOld {
|
||||
abstract val filter: Props<*>
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("Text")
|
||||
data class TextFilter(
|
||||
data class TextFilterOld(
|
||||
override val filter: TextProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class TextProps(
|
||||
override val name: String,
|
||||
@@ -11,9 +11,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TriState")
|
||||
data class TriStateFilter(
|
||||
data class TriStateFilterOld(
|
||||
override val filter: TriStateProps,
|
||||
) : SourceFilter() {
|
||||
) : SourceFilterOld() {
|
||||
@Serializable
|
||||
data class TriStateProps(
|
||||
override val name: String,
|
||||
@@ -13,6 +13,6 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName("CheckBoxPreference")
|
||||
@Immutable
|
||||
data class CheckBoxPreference(
|
||||
data class CheckBoxPreferenceOld(
|
||||
override val props: TwoStateProps,
|
||||
) : SourcePreference()
|
||||
) : SourcePreferenceOld()
|
||||
@@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName("EditTextPreference")
|
||||
@Immutable
|
||||
data class EditTextPreference(
|
||||
data class EditTextPreferenceOld(
|
||||
override val props: EditTextProps,
|
||||
) : SourcePreference() {
|
||||
) : SourcePreferenceOld() {
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class EditTextProps(
|
||||
@@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName("ListPreference")
|
||||
@Immutable
|
||||
data class ListPreference(
|
||||
data class ListPreferenceOld(
|
||||
override val props: ListProps,
|
||||
) : SourcePreference() {
|
||||
) : SourcePreferenceOld() {
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class ListProps(
|
||||
@@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName("MultiSelectListPreference")
|
||||
@Immutable
|
||||
data class MultiSelectListPreference(
|
||||
data class MultiSelectListPreferenceOld(
|
||||
override val props: MultiSelectListProps,
|
||||
) : SourcePreference() {
|
||||
) : SourcePreferenceOld() {
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class MultiSelectListProps(
|
||||
@@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@Immutable
|
||||
sealed class SourcePreference {
|
||||
sealed class SourcePreferenceOld {
|
||||
abstract val props: Props<*>
|
||||
}
|
||||
|
||||
@@ -24,3 +24,71 @@ interface Props<T> {
|
||||
val defaultValue: T
|
||||
val defaultValueType: String
|
||||
}
|
||||
|
||||
sealed interface SourcePreference {
|
||||
val position: Int
|
||||
}
|
||||
|
||||
data class SwitchSourcePreference(
|
||||
override val position: Int,
|
||||
val key: String?,
|
||||
val title: String?,
|
||||
val summary: String?,
|
||||
val visible: Boolean,
|
||||
val enabled: Boolean,
|
||||
val currentValue: Boolean?,
|
||||
val default: Boolean,
|
||||
) : SourcePreference
|
||||
|
||||
data class CheckBoxSourcePreference(
|
||||
override val position: Int,
|
||||
val key: String?,
|
||||
val title: String?,
|
||||
val summary: String?,
|
||||
val visible: Boolean,
|
||||
val enabled: Boolean,
|
||||
val currentValue: Boolean?,
|
||||
val default: Boolean,
|
||||
) : SourcePreference
|
||||
|
||||
data class EditTextSourcePreference(
|
||||
override val position: Int,
|
||||
val key: String?,
|
||||
val title: String?,
|
||||
val summary: String?,
|
||||
val visible: Boolean,
|
||||
val enabled: Boolean,
|
||||
val currentValue: String?,
|
||||
val default: String?,
|
||||
val dialogTitle: String?,
|
||||
val dialogMessage: String?,
|
||||
val text: String?,
|
||||
) : SourcePreference
|
||||
|
||||
data class ListSourcePreference(
|
||||
override val position: Int,
|
||||
val key: String?,
|
||||
val title: String?,
|
||||
val summary: String?,
|
||||
val visible: Boolean,
|
||||
val enabled: Boolean,
|
||||
val currentValue: String?,
|
||||
val default: String?,
|
||||
val entries: List<String>,
|
||||
val entryValues: List<String>,
|
||||
) : SourcePreference
|
||||
|
||||
data class MultiSelectListSourcePreference(
|
||||
override val position: Int,
|
||||
val key: String?,
|
||||
val title: String?,
|
||||
val summary: String?,
|
||||
val visible: Boolean,
|
||||
val enabled: Boolean,
|
||||
val currentValue: List<String>?,
|
||||
val default: List<String>?,
|
||||
val dialogTitle: String?,
|
||||
val dialogMessage: String?,
|
||||
val entries: List<String>,
|
||||
val entryValues: List<String>,
|
||||
) : SourcePreference
|
||||
|
||||
@@ -13,6 +13,6 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName("SwitchPreferenceCompat")
|
||||
@Immutable
|
||||
data class SwitchPreference(
|
||||
data class SwitchPreferenceOld(
|
||||
override val props: TwoStateProps,
|
||||
) : SourcePreference()
|
||||
) : SourcePreferenceOld()
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.source.service
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.MangaPage
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilter
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreference
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface SourceRepository {
|
||||
|
||||
fun getSourceList(): Flow<List<Source>>
|
||||
|
||||
fun getSourceInfo(
|
||||
sourceId: Long,
|
||||
): Flow<Source>
|
||||
|
||||
fun getPopularManga(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
): Flow<MangaPage>
|
||||
|
||||
fun getLatestManga(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
): Flow<MangaPage>
|
||||
|
||||
fun getFilterList(
|
||||
sourceId: Long,
|
||||
): Flow<List<SourceFilter>>
|
||||
|
||||
fun getSearchResults(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
searchTerm: String?,
|
||||
filters: List<SourceFilter>?,
|
||||
): Flow<MangaPage>
|
||||
|
||||
fun getSourceSettings(
|
||||
sourceId: Long,
|
||||
): Flow<List<SourcePreference>>
|
||||
|
||||
fun setSourceSetting(
|
||||
sourceId: Long,
|
||||
sourcePreference: SourcePreference,
|
||||
): Flow<Unit>
|
||||
}
|
||||
@@ -8,11 +8,11 @@ package ca.gosyer.jui.domain.source.service
|
||||
|
||||
import ca.gosyer.jui.domain.source.model.MangaPage
|
||||
import ca.gosyer.jui.domain.source.model.Source
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilter
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterChange
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterChangeOld
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterData
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreference
|
||||
import ca.gosyer.jui.domain.source.model.sourcefilters.SourceFilterOld
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreferenceChange
|
||||
import ca.gosyer.jui.domain.source.model.sourcepreference.SourcePreferenceOld
|
||||
import de.jensklingenberg.ktorfit.http.Body
|
||||
import de.jensklingenberg.ktorfit.http.GET
|
||||
import de.jensklingenberg.ktorfit.http.Headers
|
||||
@@ -54,20 +54,20 @@ interface SourceRepositoryOld {
|
||||
fun getFilterList(
|
||||
@Path("sourceId") sourceId: Long,
|
||||
@Query("reset") reset: Boolean = false,
|
||||
): Flow<List<SourceFilter>>
|
||||
): Flow<List<SourceFilterOld>>
|
||||
|
||||
@POST("api/v1/source/{sourceId}/filters")
|
||||
@Headers("Content-Type: application/json")
|
||||
fun setFilter(
|
||||
@Path("sourceId") sourceId: Long,
|
||||
@Body sourceFilter: SourceFilterChange,
|
||||
@Body sourceFilter: SourceFilterChangeOld,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@POST("api/v1/source/{sourceId}/filters")
|
||||
@Headers("Content-Type: application/json")
|
||||
fun setFilters(
|
||||
@Path("sourceId") sourceId: Long,
|
||||
@Body sourceFilters: List<SourceFilterChange>,
|
||||
@Body sourceFilters: List<SourceFilterChangeOld>,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@POST("api/v1/source/{sourceId}/quick-search")
|
||||
@@ -81,7 +81,7 @@ interface SourceRepositoryOld {
|
||||
@GET("api/v1/source/{sourceId}/preferences")
|
||||
fun getSourceSettings(
|
||||
@Path("sourceId") sourceId: Long,
|
||||
): Flow<List<SourcePreference>>
|
||||
): Flow<List<SourcePreferenceOld>>
|
||||
|
||||
@POST("api/v1/source/{sourceId}/preferences")
|
||||
@Headers("Content-Type: application/json")
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.updates.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepositoryOld
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.singleOrNull
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class GetRecentUpdates
|
||||
@Inject
|
||||
constructor(
|
||||
private val updatesRepositoryOld: UpdatesRepositoryOld,
|
||||
private val updatesRepository: UpdatesRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
pageNum: Int,
|
||||
@@ -27,7 +27,7 @@ class GetRecentUpdates
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(pageNum: Int) = updatesRepositoryOld.getRecentUpdates(pageNum)
|
||||
fun asFlow(pageNum: Int) = updatesRepository.getRecentUpdates(pageNum)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ca.gosyer.jui.domain.updates.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.category.model.Category
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepositoryOld
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -16,7 +16,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateCategory
|
||||
@Inject
|
||||
constructor(
|
||||
private val updatesRepositoryOld: UpdatesRepositoryOld,
|
||||
private val updatesRepository: UpdatesRepository,
|
||||
) {
|
||||
suspend fun await(
|
||||
categoryId: Long,
|
||||
@@ -38,9 +38,9 @@ class UpdateCategory
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow(categoryId: Long) = updatesRepositoryOld.updateCategory(categoryId)
|
||||
fun asFlow(categoryId: Long) = updatesRepository.updateCategory(categoryId)
|
||||
|
||||
fun asFlow(category: Category) = updatesRepositoryOld.updateCategory(category.id)
|
||||
fun asFlow(category: Category) = updatesRepository.updateCategory(category.id)
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package ca.gosyer.jui.domain.updates.interactor
|
||||
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepositoryOld
|
||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
@@ -15,7 +15,7 @@ import org.lighthousegames.logging.logging
|
||||
class UpdateLibrary
|
||||
@Inject
|
||||
constructor(
|
||||
private val updatesRepositoryOld: UpdatesRepositoryOld,
|
||||
private val updatesRepository: UpdatesRepository,
|
||||
) {
|
||||
suspend fun await(onError: suspend (Throwable) -> Unit = {}) =
|
||||
asFlow()
|
||||
@@ -25,7 +25,7 @@ class UpdateLibrary
|
||||
}
|
||||
.collect()
|
||||
|
||||
fun asFlow() = updatesRepositoryOld.updateLibrary()
|
||||
fun asFlow() = updatesRepository.updateLibrary()
|
||||
|
||||
companion object {
|
||||
private val log = logging()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.jui.domain.updates.service
|
||||
|
||||
import ca.gosyer.jui.domain.updates.model.Updates
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface UpdatesRepository {
|
||||
fun getRecentUpdates(
|
||||
pageNum: Int,
|
||||
): Flow<Updates>
|
||||
|
||||
fun updateLibrary(): Flow<Unit>
|
||||
|
||||
fun updateCategory(
|
||||
categoryId: Long,
|
||||
): Flow<Unit>
|
||||
}
|
||||
Reference in New Issue
Block a user