From e9190aeb2affe760fbdddd7a6432c2eb9f3253f3 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Tue, 7 Oct 2025 12:34:31 -0400 Subject: [PATCH] Remove unused interactors --- .../interactor/UpdateChapterLastPageRead.kt | 66 ---------------- .../chapter/interactor/UpdateChapterRead.kt | 75 ------------------- 2 files changed, 141 deletions(-) delete mode 100644 domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterLastPageRead.kt delete mode 100644 domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterRead.kt diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterLastPageRead.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterLastPageRead.kt deleted file mode 100644 index 3407320a..00000000 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterLastPageRead.kt +++ /dev/null @@ -1,66 +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.chapter.interactor - -import ca.gosyer.jui.domain.ServerListeners -import ca.gosyer.jui.domain.chapter.model.Chapter -import ca.gosyer.jui.domain.chapter.service.ChapterRepository -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.onEach -import me.tatarka.inject.annotations.Inject -import org.lighthousegames.logging.logging - -@Inject -class UpdateChapterLastPageRead( - private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, -) { - suspend fun await( - chapterId: Long, - mangaId: Long?, - lastPageRead: Int, - onError: suspend (Throwable) -> Unit = {}, - ) = asFlow(chapterId, mangaId, lastPageRead) - .catch { - onError(it) - log.warn(it) { "Failed to update chapter last page read for chapter $chapterId" } - } - .collect() - - suspend fun await( - chapter: Chapter, - lastPageRead: Int, - onError: suspend (Throwable) -> Unit = {}, - ) = asFlow(chapter, lastPageRead) - .catch { - onError(it) - log.warn(it) { "Failed to update chapter last page read for chapter ${chapter.index} of ${chapter.mangaId}" } - } - .collect() - - fun asFlow( - chapterId: Long, - mangaId: Long?, - lastPageRead: Int, - ) = chapterRepository.updateChapter( - chapterId = chapterId, - lastPageRead = lastPageRead, - ).onEach { serverListeners.updateManga(mangaId ?: -1) } - - fun asFlow( - chapter: Chapter, - lastPageRead: Int, - ) = chapterRepository.updateChapter( - chapterId = chapter.id, - lastPageRead = lastPageRead, - ).onEach { serverListeners.updateManga(chapter.mangaId) } - - companion object { - private val log = logging() - } -} diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterRead.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterRead.kt deleted file mode 100644 index aab90e5e..00000000 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterRead.kt +++ /dev/null @@ -1,75 +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.chapter.interactor - -import ca.gosyer.jui.domain.ServerListeners -import ca.gosyer.jui.domain.chapter.model.Chapter -import ca.gosyer.jui.domain.chapter.service.ChapterRepository -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.onEach -import me.tatarka.inject.annotations.Inject -import org.lighthousegames.logging.logging - -@Inject -class UpdateChapterRead( - private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, -) { - suspend fun await( - chapterId: Long, - mangaId: Long?, - read: Boolean, - onError: suspend (Throwable) -> Unit = {}, - ) = asFlow(chapterId, mangaId, read) - .catch { - onError(it) - log.warn(it) { "Failed to update chapter read status for chapter $chapterId" } - } - .collect() - - suspend fun await( - chapter: Chapter, - read: Boolean, - onError: suspend (Throwable) -> Unit = {}, - ) = asFlow(chapter, read) - .catch { - onError(it) - log.warn(it) { "Failed to update chapter read status for chapter ${chapter.index} of ${chapter.mangaId}" } - } - .collect() - - fun asFlow( - chapterId: Long, - mangaId: Long?, - read: Boolean, - ) = chapterRepository.updateChapter( - chapterId = chapterId, - read = read, - ).onEach { serverListeners.updateManga(mangaId ?: -1) } - - fun asFlow( - chapterIds: List, - mangaIds: List?, - read: Boolean, - ) = chapterRepository.updateChapters( - chapterIds = chapterIds, - read = read, - ).onEach { serverListeners.updateManga(mangaIds.orEmpty()) } - - fun asFlow( - chapter: Chapter, - read: Boolean, - ) = chapterRepository.updateChapter( - chapterId = chapter.id, - read = read, - ).onEach { serverListeners.updateManga(chapter.mangaId) } - - companion object { - private val log = logging() - } -}