mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Lint
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
package ca.gosyer.jui.data
|
||||
|
||||
actual interface SharedDataComponent {
|
||||
}
|
||||
actual interface SharedDataComponent
|
||||
|
||||
@@ -28,9 +28,8 @@ class BackupRepositoryImpl(
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
) : BackupRepository {
|
||||
|
||||
override fun validateBackup(source: Source): Flow<BackupValidationResult> {
|
||||
return apolloClient.query(
|
||||
override fun validateBackup(source: Source): Flow<BackupValidationResult> =
|
||||
apolloClient.query(
|
||||
ValidateBackupQuery(
|
||||
DefaultUpload.Builder()
|
||||
.content {
|
||||
@@ -38,21 +37,20 @@ class BackupRepositoryImpl(
|
||||
}
|
||||
.fileName("backup.tachibk")
|
||||
.contentType("application/octet-stream")
|
||||
.build()
|
||||
)
|
||||
.build(),
|
||||
),
|
||||
).toFlow()
|
||||
.map {
|
||||
BackupValidationResult(
|
||||
missingSources = it.dataAssertNoErrors.validateBackup.missingSources.map { source ->
|
||||
"${source.name} (${source.id})"
|
||||
},
|
||||
missingTrackers = emptyList()
|
||||
missingTrackers = emptyList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun restoreBackup(source: Source): Flow<Pair<String, RestoreStatus>> {
|
||||
return apolloClient.mutation(
|
||||
override fun restoreBackup(source: Source): Flow<Pair<String, RestoreStatus>> =
|
||||
apolloClient.mutation(
|
||||
RestoreBackupMutation(
|
||||
DefaultUpload.Builder()
|
||||
.content {
|
||||
@@ -60,8 +58,8 @@ class BackupRepositoryImpl(
|
||||
}
|
||||
.fileName("backup.tachibk")
|
||||
.contentType("application/octet-stream")
|
||||
.build()
|
||||
)
|
||||
.build(),
|
||||
),
|
||||
).toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
@@ -69,54 +67,52 @@ class BackupRepositoryImpl(
|
||||
.restoreStatusFragment
|
||||
.toRestoreStatus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun restoreStatus(id: String): Flow<RestoreStatus> {
|
||||
return apolloClient.query(
|
||||
RestoreStatusQuery(id)
|
||||
override fun restoreStatus(id: String): Flow<RestoreStatus> =
|
||||
apolloClient.query(
|
||||
RestoreStatusQuery(id),
|
||||
).toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.restoreStatus!!.restoreStatusFragment.toRestoreStatus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun createBackup(
|
||||
includeCategories: Boolean,
|
||||
includeChapters: Boolean,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<Pair<String, Source>> {
|
||||
return apolloClient
|
||||
): Flow<Pair<String, Source>> =
|
||||
apolloClient
|
||||
.mutation(
|
||||
CreateBackupMutation(includeCategories, includeChapters)
|
||||
CreateBackupMutation(includeCategories, includeChapters),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val url = it.dataAssertNoErrors.createBackup.url
|
||||
val response = http.get(
|
||||
Url("$serverUrl${url}")
|
||||
Url("$serverUrl$url"),
|
||||
)
|
||||
val fileName = response.headers["content-disposition"]!!
|
||||
.substringAfter("filename=")
|
||||
.trim('"')
|
||||
fileName to response.bodyAsChannel().toSource()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun RestoreStatusFragment.toRestoreStatus() = RestoreStatus(
|
||||
when (state) {
|
||||
BackupRestoreState.IDLE -> RestoreState.IDLE
|
||||
BackupRestoreState.SUCCESS -> RestoreState.SUCCESS
|
||||
BackupRestoreState.FAILURE -> RestoreState.FAILURE
|
||||
BackupRestoreState.RESTORING_CATEGORIES -> RestoreState.RESTORING_CATEGORIES
|
||||
BackupRestoreState.RESTORING_MANGA -> RestoreState.RESTORING_MANGA
|
||||
BackupRestoreState.RESTORING_META -> RestoreState.RESTORING_META
|
||||
BackupRestoreState.RESTORING_SETTINGS -> RestoreState.RESTORING_SETTINGS
|
||||
BackupRestoreState.UNKNOWN__ -> RestoreState.UNKNOWN
|
||||
},
|
||||
mangaProgress,
|
||||
totalManga,
|
||||
)
|
||||
private fun RestoreStatusFragment.toRestoreStatus() =
|
||||
RestoreStatus(
|
||||
when (state) {
|
||||
BackupRestoreState.IDLE -> RestoreState.IDLE
|
||||
BackupRestoreState.SUCCESS -> RestoreState.SUCCESS
|
||||
BackupRestoreState.FAILURE -> RestoreState.FAILURE
|
||||
BackupRestoreState.RESTORING_CATEGORIES -> RestoreState.RESTORING_CATEGORIES
|
||||
BackupRestoreState.RESTORING_MANGA -> RestoreState.RESTORING_MANGA
|
||||
BackupRestoreState.RESTORING_META -> RestoreState.RESTORING_META
|
||||
BackupRestoreState.RESTORING_SETTINGS -> RestoreState.RESTORING_SETTINGS
|
||||
BackupRestoreState.UNKNOWN__ -> RestoreState.UNKNOWN
|
||||
},
|
||||
mangaProgress,
|
||||
totalManga,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,142 +32,131 @@ class CategoryRepositoryImpl(
|
||||
private val apolloClient: ApolloClient,
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
): CategoryRepository {
|
||||
override fun getMangaCategories(mangaId: Long): Flow<List<Category>> {
|
||||
return apolloClient.query(
|
||||
GetMangaCategoriesQuery(mangaId.toInt())
|
||||
) : CategoryRepository {
|
||||
override fun getMangaCategories(mangaId: Long): Flow<List<Category>> =
|
||||
apolloClient.query(
|
||||
GetMangaCategoriesQuery(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.manga.categories.nodes.map { it.categoryFragment.toCategory() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMangaToCategory(
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
AddMangaToCategoriesMutation(mangaId.toInt(), listOf(categoryId.toInt()))
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
AddMangaToCategoriesMutation(mangaId.toInt(), listOf(categoryId.toInt())),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateMangaCategories!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMangaFromCategory(
|
||||
mangaId: Long,
|
||||
categoryId: Long,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
RemoveMangaFromCategoriesMutation(mangaId.toInt(), listOf(categoryId.toInt()))
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
RemoveMangaFromCategoriesMutation(mangaId.toInt(), listOf(categoryId.toInt())),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateMangaCategories!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCategories(): Flow<List<Category>> {
|
||||
return apolloClient.query(
|
||||
GetCategoriesQuery()
|
||||
override fun getCategories(): Flow<List<Category>> =
|
||||
apolloClient.query(
|
||||
GetCategoriesQuery(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.categories.nodes.map { it.categoryFragment.toCategory() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun createCategory(name: String): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
CreateCategoryMutation(name)
|
||||
override fun createCategory(name: String): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
CreateCategoryMutation(name),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.createCategory!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun modifyCategory(
|
||||
categoryId: Long,
|
||||
name: String,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
ModifyCategoryMutation(categoryId.toInt(), name)
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
ModifyCategoryMutation(categoryId.toInt(), name),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateCategory!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun reorderCategory(
|
||||
categoryId: Long,
|
||||
position: Int,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
ReorderCategoryMutation(categoryId.toInt(), position)
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
ReorderCategoryMutation(categoryId.toInt(), position),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateCategoryOrder!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteCategory(categoryId: Long): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
DeleteCategoryMutation(categoryId.toInt())
|
||||
override fun deleteCategory(categoryId: Long): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
DeleteCategoryMutation(categoryId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.deleteCategory!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMangaFromCategory(categoryId: Long): Flow<List<Manga>> {
|
||||
return apolloClient.query(
|
||||
GetCategoryMangaQuery(listOf(categoryId.toInt()))
|
||||
override fun getMangaFromCategory(categoryId: Long): Flow<List<Manga>> =
|
||||
apolloClient.query(
|
||||
GetCategoryMangaQuery(listOf(categoryId.toInt())),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.mangas.nodes.map { it.mangaFragment.toManga() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateCategoryMeta(
|
||||
categoryId: Long,
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
SetCategoryMetaMutation(categoryId.toInt(), key, value)
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
SetCategoryMetaMutation(categoryId.toInt(), key, value),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.setCategoryMeta!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun CategoryFragment.toCategory(): Category {
|
||||
return Category(
|
||||
internal fun CategoryFragment.toCategory(): Category =
|
||||
Category(
|
||||
id = id.toLong(),
|
||||
order = order,
|
||||
name = name,
|
||||
default = default,
|
||||
meta = CategoryMeta()
|
||||
meta = CategoryMeta(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,145 +33,130 @@ class ChapterRepositoryImpl(
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
) : ChapterRepository {
|
||||
override fun getChapter(chapterId: Long): Flow<Chapter> {
|
||||
return apolloClient.query(
|
||||
GetChapterQuery(chapterId.toInt())
|
||||
override fun getChapter(chapterId: Long): Flow<Chapter> =
|
||||
apolloClient.query(
|
||||
GetChapterQuery(chapterId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.chapter.chapterFragment.toChapter()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getChapters(mangaId: Long): Flow<List<Chapter>> {
|
||||
return apolloClient.query(
|
||||
GetMangaChaptersQuery(mangaId.toInt())
|
||||
override fun getChapters(mangaId: Long): Flow<List<Chapter>> =
|
||||
apolloClient.query(
|
||||
GetMangaChaptersQuery(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.chapters.nodes.map { it.chapterFragment.toChapter() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateChapter(
|
||||
chapterId: Long,
|
||||
bookmarked: Boolean?,
|
||||
read: Boolean?,
|
||||
lastPageRead: Int?,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateChapterMutation(
|
||||
chapterId.toInt(),
|
||||
UpdateChapterPatchInput(
|
||||
isBookmarked = Optional.presentIfNotNull(bookmarked),
|
||||
isRead = Optional.presentIfNotNull(read),
|
||||
lastPageRead = Optional.presentIfNotNull(lastPageRead)
|
||||
lastPageRead = Optional.presentIfNotNull(lastPageRead),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateChapters(
|
||||
chapterIds: List<Long>,
|
||||
bookmarked: Boolean?,
|
||||
read: Boolean?,
|
||||
lastPageRead: Int?,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateChaptersMutation(
|
||||
chapterIds.map { it.toInt() },
|
||||
UpdateChapterPatchInput(
|
||||
isBookmarked = Optional.presentIfNotNull(bookmarked),
|
||||
isRead = Optional.presentIfNotNull(read),
|
||||
lastPageRead = Optional.presentIfNotNull(lastPageRead)
|
||||
lastPageRead = Optional.presentIfNotNull(lastPageRead),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteDownloadedChapter(
|
||||
chapterId: Long,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
override fun deleteDownloadedChapter(chapterId: Long): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
DeleteDownloadedChapterMutation(
|
||||
chapterId.toInt(),
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteDownloadedChapters(
|
||||
chapterIds: List<Long>,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
override fun deleteDownloadedChapters(chapterIds: List<Long>): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
DeleteDownloadedChaptersMutation(
|
||||
chapterIds.map { it.toInt() },
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateChapterMeta(
|
||||
chapterId: Long,
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateChapterMetaMutation(
|
||||
chapterId.toInt(),
|
||||
key,
|
||||
value,
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun fetchChapters(
|
||||
mangaId: Long,
|
||||
): Flow<List<Chapter>> {
|
||||
return apolloClient.mutation(
|
||||
override fun fetchChapters(mangaId: Long): Flow<List<Chapter>> =
|
||||
apolloClient.mutation(
|
||||
FetchChaptersMutation(
|
||||
mangaId.toInt(),
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val chapters = it.dataAssertNoErrors
|
||||
chapters.fetchChapters!!.chapters.map { it.chapterFragment.toChapter() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPages(chapterId: Long): Flow<List<String>> {
|
||||
return apolloClient.mutation(
|
||||
override fun getPages(chapterId: Long): Flow<List<String>> =
|
||||
apolloClient.mutation(
|
||||
FetchChapterPagesMutation(
|
||||
chapterId.toInt(),
|
||||
)
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val chapters = it.dataAssertNoErrors
|
||||
chapters.fetchChapterPages!!.pages
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPage(
|
||||
url: String,
|
||||
@@ -182,10 +167,9 @@ class ChapterRepositoryImpl(
|
||||
return flow { http.get(realUrl, block).readBytes() }
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
internal fun ChapterFragment.toChapter(): Chapter {
|
||||
return Chapter(
|
||||
internal fun ChapterFragment.toChapter(): Chapter =
|
||||
Chapter(
|
||||
id = id.toLong(),
|
||||
url = url,
|
||||
name = name,
|
||||
@@ -203,16 +187,14 @@ class ChapterRepositoryImpl(
|
||||
lastReadAt = lastPageRead,
|
||||
downloaded = isDownloaded,
|
||||
meta = ChapterMeta(
|
||||
juiPageOffset = meta.find { it.key == "juiPageOffset" }?.value?.toIntOrNull() ?: 0
|
||||
)
|
||||
juiPageOffset = meta.find { it.key == "juiPageOffset" }?.value?.toIntOrNull() ?: 0,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
internal fun ChapterWithMangaFragment.toMangaAndChapter(): MangaAndChapter {
|
||||
return MangaAndChapter(
|
||||
internal fun ChapterWithMangaFragment.toMangaAndChapter(): MangaAndChapter =
|
||||
MangaAndChapter(
|
||||
manga.mangaFragment.toManga(),
|
||||
chapterFragment.toChapter(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,79 +24,70 @@ class DownloadRepositoryImpl(
|
||||
private val apolloClient: ApolloClient,
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
): DownloadRepository {
|
||||
override fun startDownloading(): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
StartDownloaderMutation()
|
||||
) : DownloadRepository {
|
||||
override fun startDownloading(): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
StartDownloaderMutation(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun stopDownloading(): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
StopDownloaderMutation()
|
||||
override fun stopDownloading(): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
StopDownloaderMutation(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearDownloadQueue(): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
ClearDownloaderMutation()
|
||||
override fun clearDownloadQueue(): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
ClearDownloaderMutation(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun queueChapterDownload(chapterId: Long): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
EnqueueChapterDownloadMutation(chapterId.toInt())
|
||||
override fun queueChapterDownload(chapterId: Long): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
EnqueueChapterDownloadMutation(chapterId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun stopChapterDownload(chapterId: Long): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
DequeueChapterDownloadMutation(chapterId.toInt())
|
||||
override fun stopChapterDownload(chapterId: Long): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
DequeueChapterDownloadMutation(chapterId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun reorderChapterDownload(
|
||||
chapterId: Long,
|
||||
to: Int,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
ReorderChapterDownloadMutation(chapterId.toInt(), to)
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
ReorderChapterDownloadMutation(chapterId.toInt(), to),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
override fun batchDownload(chapterIds: List<Long>): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
EnqueueChapterDownloadsMutation(chapterIds.map { it.toInt() })
|
||||
override fun batchDownload(chapterIds: List<Long>): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
EnqueueChapterDownloadsMutation(chapterIds.map { it.toInt() }),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,19 +26,18 @@ class ExtensionRepositoryImpl(
|
||||
private val apolloClient: ApolloClient,
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
): ExtensionRepository {
|
||||
override fun getExtensionList(): Flow<List<Extension>> {
|
||||
return apolloClient.mutation(
|
||||
FetchExtensionsMutation()
|
||||
) : ExtensionRepository {
|
||||
override fun getExtensionList(): Flow<List<Extension>> =
|
||||
apolloClient.mutation(
|
||||
FetchExtensionsMutation(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.fetchExtensions!!.extensions.map { it.extensionFragment.toExtension() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun installExtension(source: Source): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
override fun installExtension(source: Source): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
InstallExternalExtensionMutation(
|
||||
DefaultUpload.Builder()
|
||||
.content {
|
||||
@@ -46,48 +45,44 @@ class ExtensionRepositoryImpl(
|
||||
}
|
||||
.fileName("extension.apk")
|
||||
.contentType("application/octet-stream")
|
||||
.build()
|
||||
)
|
||||
.build(),
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.installExternalExtension!!
|
||||
}
|
||||
}
|
||||
|
||||
override fun installExtension(pkgName: String): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
InstallExtensionMutation(pkgName)
|
||||
override fun installExtension(pkgName: String): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
InstallExtensionMutation(pkgName),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.updateExtension
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateExtension(pkgName: String): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
UpdateExtensionMutation(pkgName)
|
||||
override fun updateExtension(pkgName: String): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateExtensionMutation(pkgName),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.updateExtension
|
||||
}
|
||||
}
|
||||
|
||||
override fun uninstallExtension(pkgName: String): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
UninstallExtensionMutation(pkgName)
|
||||
override fun uninstallExtension(pkgName: String): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UninstallExtensionMutation(pkgName),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.updateExtension
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun ExtensionFragment.toExtension(): Extension {
|
||||
return Extension(
|
||||
internal fun ExtensionFragment.toExtension(): Extension =
|
||||
Extension(
|
||||
name = name,
|
||||
pkgName = pkgName,
|
||||
versionName = versionName,
|
||||
@@ -100,6 +95,5 @@ class ExtensionRepositoryImpl(
|
||||
obsolete = isObsolete,
|
||||
isNsfw = isNsfw,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,28 +20,27 @@ class GlobalRepositoryImpl(
|
||||
private val apolloClient: ApolloClient,
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
): GlobalRepository {
|
||||
|
||||
override fun getGlobalMeta(): Flow<GlobalMeta> {
|
||||
return apolloClient.query(
|
||||
GetGlobalMetaQuery()
|
||||
) : GlobalRepository {
|
||||
override fun getGlobalMeta(): Flow<GlobalMeta> =
|
||||
apolloClient.query(
|
||||
GetGlobalMetaQuery(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
GlobalMeta(data.metas.nodes.find { it.key == "example" }?.value?.toIntOrNull() ?: 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateGlobalMeta(key: String, value: String): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
SetGlobalMetaMutation(key, value)
|
||||
override fun updateGlobalMeta(
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
SetGlobalMetaMutation(key, value),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.setGlobalMeta!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,22 +13,20 @@ class LibraryRepositoryImpl(
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
) : LibraryRepository {
|
||||
fun setMangaInLibrary(mangaId: Long, inLibrary: Boolean): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
SetMangaInLibraryMutation(mangaId.toInt(), inLibrary)
|
||||
fun setMangaInLibrary(
|
||||
mangaId: Long,
|
||||
inLibrary: Boolean,
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
SetMangaInLibraryMutation(mangaId.toInt(), inLibrary),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateManga!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMangaToLibrary(mangaId: Long): Flow<Unit> {
|
||||
return setMangaInLibrary(mangaId, true)
|
||||
}
|
||||
override fun addMangaToLibrary(mangaId: Long): Flow<Unit> = setMangaInLibrary(mangaId, true)
|
||||
|
||||
override fun removeMangaFromLibrary(mangaId: Long): Flow<Unit> {
|
||||
return setMangaInLibrary(mangaId, false)
|
||||
}
|
||||
override fun removeMangaFromLibrary(mangaId: Long): Flow<Unit> = setMangaInLibrary(mangaId, false)
|
||||
}
|
||||
|
||||
@@ -30,71 +30,66 @@ class MangaRepositoryImpl(
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
) : MangaRepository {
|
||||
override fun getManga(mangaId: Long): Flow<Manga> {
|
||||
return apolloClient.query(
|
||||
GetMangaQuery(mangaId.toInt())
|
||||
override fun getManga(mangaId: Long): Flow<Manga> =
|
||||
apolloClient.query(
|
||||
GetMangaQuery(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.manga.mangaFragment.toManga()
|
||||
}
|
||||
}
|
||||
|
||||
override fun refreshManga(mangaId: Long): Flow<Manga> {
|
||||
return apolloClient.mutation(
|
||||
RefreshMangaMutation(mangaId.toInt())
|
||||
override fun refreshManga(mangaId: Long): Flow<Manga> =
|
||||
apolloClient.mutation(
|
||||
RefreshMangaMutation(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.fetchManga!!.manga.mangaFragment.toManga()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMangaLibrary(mangaId: Long): Flow<Manga> {
|
||||
return apolloClient.query(
|
||||
GetMangaLibraryQuery(mangaId.toInt())
|
||||
override fun getMangaLibrary(mangaId: Long): Flow<Manga> =
|
||||
apolloClient.query(
|
||||
GetMangaLibraryQuery(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.manga.libraryMangaFragment.toManga()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMangaThumbnail(
|
||||
mangaId: Long,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<ByteReadChannel> {
|
||||
return apolloClient.query(
|
||||
GetThumbnailUrlQuery(mangaId.toInt())
|
||||
): Flow<ByteReadChannel> =
|
||||
apolloClient.query(
|
||||
GetThumbnailUrlQuery(mangaId.toInt()),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
http.get(data.manga.thumbnailUrl!!).bodyAsChannel()
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateMangaMeta(
|
||||
mangaId: Long,
|
||||
key: String,
|
||||
value: String,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
SetMangaMetaMutation(mangaId.toInt(), key, value)
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
SetMangaMetaMutation(mangaId.toInt(), key, value),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.setMangaMeta!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun MangaFragment.toManga(): Manga {
|
||||
return Manga(
|
||||
internal fun MangaFragment.toManga(): Manga =
|
||||
Manga(
|
||||
id = id.toLong(),
|
||||
sourceId = sourceId,
|
||||
url = url,
|
||||
@@ -137,10 +132,9 @@ class MangaRepositoryImpl(
|
||||
age = age,
|
||||
chaptersAge = null,
|
||||
)
|
||||
}
|
||||
|
||||
internal fun LibraryMangaFragment.toManga(): Manga {
|
||||
return Manga(
|
||||
internal fun LibraryMangaFragment.toManga(): Manga =
|
||||
Manga(
|
||||
id = id.toLong(),
|
||||
sourceId = sourceId,
|
||||
url = url,
|
||||
@@ -183,6 +177,5 @@ class MangaRepositoryImpl(
|
||||
age = age,
|
||||
chaptersAge = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ class SettingsRepositoryImpl(
|
||||
webUIUpdateCheckInterval = webUIUpdateCheckInterval,
|
||||
)
|
||||
|
||||
|
||||
private fun AuthMode.toDomain() =
|
||||
when (this) {
|
||||
AuthMode.NONE -> DomainAuthMode.NONE
|
||||
@@ -354,9 +353,9 @@ class SettingsRepositoryImpl(
|
||||
}
|
||||
.flowOn(Dispatchers.IO)
|
||||
|
||||
override fun aboutServer(): Flow<About> {
|
||||
return apolloClient.query(
|
||||
AboutServerQuery()
|
||||
override fun aboutServer(): Flow<About> =
|
||||
apolloClient.query(
|
||||
AboutServerQuery(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
@@ -370,9 +369,8 @@ class SettingsRepositoryImpl(
|
||||
},
|
||||
data.aboutServer.buildTime,
|
||||
data.aboutServer.github,
|
||||
data.aboutServer.discord
|
||||
data.aboutServer.discord,
|
||||
)
|
||||
}
|
||||
.flowOn(Dispatchers.IO)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,67 +37,61 @@ class SourceRepositoryImpl(
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
) : SourceRepository {
|
||||
override fun getSourceList(): Flow<List<Source>> {
|
||||
return apolloClient.query(
|
||||
GetSourceListQuery()
|
||||
override fun getSourceList(): Flow<List<Source>> =
|
||||
apolloClient.query(
|
||||
GetSourceListQuery(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.sources.nodes.map { it.sourceFragment.toSource() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSourceInfo(sourceId: Long): Flow<Source> {
|
||||
return apolloClient.query(
|
||||
GetSourceQuery(sourceId)
|
||||
override fun getSourceInfo(sourceId: Long): Flow<Source> =
|
||||
apolloClient.query(
|
||||
GetSourceQuery(sourceId),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.source.sourceFragment.toSource()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPopularManga(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
): Flow<MangaPage> {
|
||||
return apolloClient.mutation(
|
||||
FetchPopularMangaMutation(sourceId, pageNum)
|
||||
): Flow<MangaPage> =
|
||||
apolloClient.mutation(
|
||||
FetchPopularMangaMutation(sourceId, pageNum),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
MangaPage(
|
||||
data.fetchSourceManga!!.mangas.map { it.mangaFragment.toManga() },
|
||||
data.fetchSourceManga.hasNextPage
|
||||
data.fetchSourceManga.hasNextPage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLatestManga(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
): Flow<MangaPage> {
|
||||
return apolloClient.mutation(
|
||||
FetchLatestMangaMutation(sourceId, pageNum)
|
||||
): Flow<MangaPage> =
|
||||
apolloClient.mutation(
|
||||
FetchLatestMangaMutation(sourceId, pageNum),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
MangaPage(
|
||||
data.fetchSourceManga!!.mangas.map { it.mangaFragment.toManga() },
|
||||
data.fetchSourceManga.hasNextPage
|
||||
data.fetchSourceManga.hasNextPage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFilterList(
|
||||
sourceId: Long,
|
||||
): Flow<List<SourceFilter>> {
|
||||
return apolloClient.query(
|
||||
GetSourceFiltersQuery(sourceId)
|
||||
override fun getFilterList(sourceId: Long): Flow<List<SourceFilter>> =
|
||||
apolloClient.query(
|
||||
GetSourceFiltersQuery(sourceId),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
@@ -112,6 +106,7 @@ class SourceRepositoryImpl(
|
||||
filter.checkBoxFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"HeaderFilter" -> {
|
||||
val filter = filter.onHeaderFilter!!
|
||||
SourceFilter.Header(
|
||||
@@ -119,15 +114,17 @@ class SourceRepositoryImpl(
|
||||
filter.name,
|
||||
)
|
||||
}
|
||||
|
||||
"SelectFilter" -> {
|
||||
val filter = filter.onSelectFilter!!
|
||||
SourceFilter.Select(
|
||||
index,
|
||||
filter.name,
|
||||
filter.values,
|
||||
filter.selectFilterDefault
|
||||
filter.selectFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"TriStateFilter" -> {
|
||||
val filter = filter.onTriStateFilter!!
|
||||
SourceFilter.TriState(
|
||||
@@ -141,6 +138,7 @@ class SourceRepositoryImpl(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
"TextFilter" -> {
|
||||
val filter = filter.onTextFilter!!
|
||||
SourceFilter.Text(
|
||||
@@ -149,6 +147,7 @@ class SourceRepositoryImpl(
|
||||
filter.textFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"SortFilter" -> {
|
||||
val filter = filter.onSortFilter!!
|
||||
SourceFilter.Sort(
|
||||
@@ -160,6 +159,7 @@ class SourceRepositoryImpl(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
"SeparatorFilter" -> {
|
||||
val filter = filter.onSeparatorFilter!!
|
||||
SourceFilter.Separator(
|
||||
@@ -167,6 +167,7 @@ class SourceRepositoryImpl(
|
||||
filter.name,
|
||||
)
|
||||
}
|
||||
|
||||
"GroupFilter" -> {
|
||||
SourceFilter.Group(
|
||||
index,
|
||||
@@ -181,6 +182,7 @@ class SourceRepositoryImpl(
|
||||
filter.checkBoxFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"HeaderFilter" -> {
|
||||
val filter = filter.onHeaderFilter!!
|
||||
SourceFilter.Header(
|
||||
@@ -188,15 +190,17 @@ class SourceRepositoryImpl(
|
||||
filter.name,
|
||||
)
|
||||
}
|
||||
|
||||
"SelectFilter" -> {
|
||||
val filter = filter.onSelectFilter!!
|
||||
SourceFilter.Select(
|
||||
index,
|
||||
filter.name,
|
||||
filter.values,
|
||||
filter.selectFilterDefault
|
||||
filter.selectFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"TriStateFilter" -> {
|
||||
val filter = filter.onTriStateFilter!!
|
||||
SourceFilter.TriState(
|
||||
@@ -210,6 +214,7 @@ class SourceRepositoryImpl(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
"TextFilter" -> {
|
||||
val filter = filter.onTextFilter!!
|
||||
SourceFilter.Text(
|
||||
@@ -218,6 +223,7 @@ class SourceRepositoryImpl(
|
||||
filter.textFilterDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"SortFilter" -> {
|
||||
val filter = filter.onSortFilter!!
|
||||
SourceFilter.Sort(
|
||||
@@ -229,6 +235,7 @@ class SourceRepositoryImpl(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
"SeparatorFilter" -> {
|
||||
val filter = filter.onSeparatorFilter!!
|
||||
SourceFilter.Separator(
|
||||
@@ -236,16 +243,17 @@ class SourceRepositoryImpl(
|
||||
filter.name,
|
||||
)
|
||||
}
|
||||
|
||||
else -> SourceFilter.Header(index, "")
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
else -> SourceFilter.Header(index, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun SourceFilter.toFilterChange(): List<FilterChangeInput>? {
|
||||
return when (this) {
|
||||
@@ -254,28 +262,34 @@ class SourceRepositoryImpl(
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
is SourceFilter.Header -> null
|
||||
|
||||
is SourceFilter.Select -> if (value != default) {
|
||||
listOf(FilterChangeInput(position = position, selectState = value.toOptional()))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
is SourceFilter.Separator -> null
|
||||
|
||||
is SourceFilter.Sort -> if (value != default) {
|
||||
listOf(
|
||||
FilterChangeInput(
|
||||
position = position,
|
||||
sortState = value?.let { SortSelectionInput(it.ascending, it.index) }.toOptional()
|
||||
)
|
||||
sortState = value?.let { SortSelectionInput(it.ascending, it.index) }.toOptional(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
is SourceFilter.Text -> if (value != default) {
|
||||
listOf(FilterChangeInput(position = position, textState = value.toOptional()))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
is SourceFilter.TriState -> if (value != default) {
|
||||
listOf(
|
||||
FilterChangeInput(
|
||||
@@ -285,29 +299,31 @@ class SourceRepositoryImpl(
|
||||
TriStateValue.INCLUDE -> TriState.INCLUDE
|
||||
TriStateValue.EXCLUDE -> TriState.EXCLUDE
|
||||
}.toOptional(),
|
||||
)
|
||||
),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
is SourceFilter.Group -> value.mapNotNull {
|
||||
FilterChangeInput(
|
||||
position = position,
|
||||
groupChange = it.toFilterChange()
|
||||
?.firstOrNull()
|
||||
?.toOptional()
|
||||
?: return@mapNotNull null
|
||||
?: return@mapNotNull null,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSearchResults(
|
||||
sourceId: Long,
|
||||
pageNum: Int,
|
||||
searchTerm: String?,
|
||||
filters: List<SourceFilter>?,
|
||||
): Flow<MangaPage> {
|
||||
return apolloClient.mutation(
|
||||
): Flow<MangaPage> =
|
||||
apolloClient.mutation(
|
||||
FetchSearchMangaMutation(
|
||||
sourceId,
|
||||
pageNum,
|
||||
@@ -322,14 +338,13 @@ class SourceRepositoryImpl(
|
||||
val data = it.dataAssertNoErrors
|
||||
MangaPage(
|
||||
data.fetchSourceManga!!.mangas.map { it.mangaFragment.toManga() },
|
||||
data.fetchSourceManga.hasNextPage
|
||||
data.fetchSourceManga.hasNextPage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSourceSettings(sourceId: Long): Flow<List<SourcePreference>> {
|
||||
return apolloClient.query(
|
||||
GetSourcePreferencesQuery(sourceId)
|
||||
override fun getSourceSettings(sourceId: Long): Flow<List<SourcePreference>> =
|
||||
apolloClient.query(
|
||||
GetSourcePreferencesQuery(sourceId),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
@@ -349,6 +364,7 @@ class SourceRepositoryImpl(
|
||||
default = it.checkBoxDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"EditTextPreference" -> preference.onEditTextPreference!!.let {
|
||||
EditTextSourcePreference(
|
||||
position = index,
|
||||
@@ -364,6 +380,7 @@ class SourceRepositoryImpl(
|
||||
text = it.text,
|
||||
)
|
||||
}
|
||||
|
||||
"SwitchPreference" -> preference.onSwitchPreference!!.let {
|
||||
SwitchSourcePreference(
|
||||
position = index,
|
||||
@@ -376,6 +393,7 @@ class SourceRepositoryImpl(
|
||||
default = it.switchPreferenceDefault,
|
||||
)
|
||||
}
|
||||
|
||||
"MultiSelectListPreference" -> preference.onMultiSelectListPreference!!.let {
|
||||
MultiSelectListSourcePreference(
|
||||
position = index,
|
||||
@@ -389,9 +407,10 @@ class SourceRepositoryImpl(
|
||||
dialogTitle = it.dialogTitle,
|
||||
dialogMessage = it.dialogMessage,
|
||||
entries = it.entries,
|
||||
entryValues = it.entryValues
|
||||
entryValues = it.entryValues,
|
||||
)
|
||||
}
|
||||
|
||||
"ListPreference" -> preference.onListPreference!!.let {
|
||||
ListSourcePreference(
|
||||
position = index,
|
||||
@@ -403,20 +422,20 @@ class SourceRepositoryImpl(
|
||||
currentValue = it.listPreferenceCurrentValue,
|
||||
default = it.listPreferenceDefault,
|
||||
entries = it.entries,
|
||||
entryValues = it.entryValues
|
||||
entryValues = it.entryValues,
|
||||
)
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setSourceSetting(
|
||||
sourceId: Long,
|
||||
sourcePreference: SourcePreference,
|
||||
): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
SetSourceSettingMutation(
|
||||
sourceId,
|
||||
SourcePreferenceChangeInput(
|
||||
@@ -426,18 +445,17 @@ class SourceRepositoryImpl(
|
||||
editTextState = (sourcePreference as? EditTextSourcePreference)?.currentValue.toOptional(),
|
||||
multiSelectState = (sourcePreference as? MultiSelectListSourcePreference)?.currentValue.toOptional(),
|
||||
listState = (sourcePreference as? ListSourcePreference)?.currentValue.toOptional(),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
it.dataAssertNoErrors.updateSourcePreference!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun SourceFragment.toSource(): Source {
|
||||
return Source(
|
||||
internal fun SourceFragment.toSource(): Source =
|
||||
Source(
|
||||
id,
|
||||
name,
|
||||
lang,
|
||||
@@ -445,8 +463,7 @@ class SourceRepositoryImpl(
|
||||
supportsLatest,
|
||||
isConfigurable,
|
||||
isNsfw,
|
||||
displayName
|
||||
displayName,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,42 +22,37 @@ class UpdatesRepositoryImpl(
|
||||
private val apolloClient: ApolloClient,
|
||||
private val http: Http,
|
||||
private val serverUrl: Url,
|
||||
): UpdatesRepository {
|
||||
override fun getRecentUpdates(pageNum: Int): Flow<Updates> {
|
||||
return apolloClient.query(
|
||||
GetChapterUpdatesQuery(50, pageNum * 50)
|
||||
) : UpdatesRepository {
|
||||
override fun getRecentUpdates(pageNum: Int): Flow<Updates> =
|
||||
apolloClient.query(
|
||||
GetChapterUpdatesQuery(50, pageNum * 50),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
Updates(
|
||||
data.chapters.nodes.map { it.chapterWithMangaFragment.toMangaAndChapter() },
|
||||
data.chapters.pageInfo.hasNextPage
|
||||
data.chapters.pageInfo.hasNextPage,
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateLibrary(): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
UpdateLibraryMutation()
|
||||
override fun updateLibrary(): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateLibraryMutation(),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateLibraryManga!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateCategory(categoryId: Long): Flow<Unit> {
|
||||
return apolloClient.mutation(
|
||||
UpdateCategoryMutation(listOf(categoryId.toInt()))
|
||||
override fun updateCategory(categoryId: Long): Flow<Unit> =
|
||||
apolloClient.mutation(
|
||||
UpdateCategoryMutation(listOf(categoryId.toInt())),
|
||||
)
|
||||
.toFlow()
|
||||
.map {
|
||||
val data = it.dataAssertNoErrors
|
||||
data.updateCategoryManga!!.clientMutationId
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
package ca.gosyer.jui.data
|
||||
|
||||
actual interface SharedDataComponent {
|
||||
|
||||
}
|
||||
actual interface SharedDataComponent
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
package ca.gosyer.jui.data
|
||||
|
||||
actual interface SharedDataComponent {
|
||||
|
||||
}
|
||||
actual interface SharedDataComponent
|
||||
|
||||
Reference in New Issue
Block a user