diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/ServerListeners.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/ServerListeners.kt index 03e34034..b62b9536 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/ServerListeners.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/ServerListeners.kt @@ -28,23 +28,23 @@ class ServerListeners @Inject constructor() { private fun Flow.startWith(value: T) = onStart { emit(value) } private val mangaListener = MutableSharedFlow>( - extraBufferCapacity = Channel.UNLIMITED, + extraBufferCapacity = Channel.UNLIMITED ) private val chapterIndexesListener = MutableSharedFlow?>>( - extraBufferCapacity = Channel.UNLIMITED, + extraBufferCapacity = Channel.UNLIMITED ) private val chapterIdsListener = MutableSharedFlow>>( - extraBufferCapacity = Channel.UNLIMITED, + extraBufferCapacity = Channel.UNLIMITED ) private val categoryMangaListener = MutableSharedFlow( - extraBufferCapacity = Channel.UNLIMITED, + extraBufferCapacity = Channel.UNLIMITED ) private val extensionListener = MutableSharedFlow>( - extraBufferCapacity = Channel.UNLIMITED, + extraBufferCapacity = Channel.UNLIMITED ) fun combineMangaUpdates(flow: Flow, predate: (suspend (List) -> Boolean)? = null) = @@ -127,4 +127,4 @@ class ServerListeners @Inject constructor() { companion object { private val log = logging() } -} \ No newline at end of file +} diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/AddMangaToCategory.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/AddMangaToCategory.kt index aeccdee8..37dc7674 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/AddMangaToCategory.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/AddMangaToCategory.kt @@ -19,7 +19,7 @@ import org.lighthousegames.logging.logging class AddMangaToCategory @Inject constructor( private val categoryRepository: CategoryRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, categoryId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/GetMangaListFromCategory.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/GetMangaListFromCategory.kt index 60a3d417..9dadc633 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/GetMangaListFromCategory.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/GetMangaListFromCategory.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class GetMangaListFromCategory @Inject constructor( private val categoryRepository: CategoryRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(categoryId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/RemoveMangaFromCategory.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/RemoveMangaFromCategory.kt index 970c9d39..b6edd437 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/RemoveMangaFromCategory.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/category/interactor/RemoveMangaFromCategory.kt @@ -19,8 +19,8 @@ import org.lighthousegames.logging.logging class RemoveMangaFromCategory @Inject constructor( private val categoryRepository: CategoryRepository, - private val serverListeners: ServerListeners, -) { + private val serverListeners: ServerListeners +) { suspend fun await(mangaId: Long, categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, categoryId) .catch { diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/BatchUpdateChapter.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/BatchUpdateChapter.kt index 60e821da..fdda06db 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/BatchUpdateChapter.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/BatchUpdateChapter.kt @@ -22,7 +22,7 @@ import kotlin.jvm.JvmName class BatchUpdateChapter @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { @JvmName("awaitChapters") diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/DeleteChapterDownload.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/DeleteChapterDownload.kt index 7168af6d..0ecde0f0 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/DeleteChapterDownload.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/DeleteChapterDownload.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class DeleteChapterDownload @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, index: Int, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, index) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapter.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapter.kt index 7756f15f..622510a8 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapter.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapter.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class GetChapter @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, index: Int, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, index) @@ -47,7 +47,7 @@ class GetChapter @Inject constructor( fun asFlow(mangaId: Long, index: Int) = serverListeners.combineChapters( chapterRepository.getChapter(mangaId, index), - indexPredate = { id, chapterIndexes -> + indexPredate = { id, chapterIndexes -> id == mangaId && (chapterIndexes == null || index in chapterIndexes) }, idPredate = { id, _ -> id == mangaId } @@ -55,7 +55,7 @@ class GetChapter @Inject constructor( fun asFlow(manga: Manga, index: Int) = serverListeners.combineChapters( chapterRepository.getChapter(manga.id, index), - indexPredate = { id, chapterIndexes -> + indexPredate = { id, chapterIndexes -> id == manga.id && (chapterIndexes == null || index in chapterIndexes) }, idPredate = { id, _ -> id == manga.id } @@ -63,7 +63,7 @@ class GetChapter @Inject constructor( fun asFlow(chapter: Chapter) = serverListeners.combineChapters( chapterRepository.getChapter(chapter.mangaId, chapter.index), - indexPredate = { id, chapterIndexes -> + indexPredate = { id, chapterIndexes -> id == chapter.mangaId && (chapterIndexes == null || chapter.index in chapterIndexes) }, idPredate = { id, _ -> id == chapter.mangaId } diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapters.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapters.kt index 38ea54ac..ea7309c5 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapters.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/GetChapters.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class GetChapters @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) @@ -38,13 +38,13 @@ class GetChapters @Inject constructor( fun asFlow(mangaId: Long) = serverListeners.combineChapters( chapterRepository.getChapters(mangaId), - indexPredate = { id, _ -> id == mangaId }, + indexPredate = { id, _ -> id == mangaId }, idPredate = { id, _ -> id == mangaId } ) fun asFlow(manga: Manga) = serverListeners.combineChapters( chapterRepository.getChapters(manga.id), - indexPredate = { id, _ -> id == manga.id }, + indexPredate = { id, _ -> id == manga.id }, idPredate = { id, _ -> id == manga.id } ) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/RefreshChapters.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/RefreshChapters.kt index 31909809..411430f0 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/RefreshChapters.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/RefreshChapters.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class RefreshChapters @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterBookmarked.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterBookmarked.kt index df5600c5..ff932acb 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterBookmarked.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterBookmarked.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class UpdateChapterBookmarked @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await( 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 index cc5d83f6..01084f36 100644 --- 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 @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class UpdateChapterLastPageRead @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await( diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMarkPreviousRead.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMarkPreviousRead.kt index 0d560d7e..ba94d850 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMarkPreviousRead.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMarkPreviousRead.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class UpdateChapterMarkPreviousRead @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await( diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMeta.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMeta.kt index 6babdb53..31688fbf 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMeta.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/chapter/interactor/UpdateChapterMeta.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class UpdateChapterMeta @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await( 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 index a9807e69..003ff3a8 100644 --- 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 @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class UpdateChapterRead @Inject constructor( private val chapterRepository: ChapterRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await( diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/AddMangaToLibrary.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/AddMangaToLibrary.kt index 9e0ae32f..6aee2b95 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/AddMangaToLibrary.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/AddMangaToLibrary.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class AddMangaToLibrary @Inject constructor( private val libraryRepository: LibraryRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/RemoveMangaFromLibrary.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/RemoveMangaFromLibrary.kt index f77ab478..f91d8d33 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/RemoveMangaFromLibrary.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/interactor/RemoveMangaFromLibrary.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class RemoveMangaFromLibrary @Inject constructor( private val libraryRepository: LibraryRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetManga.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetManga.kt index 7e2fb1c4..f2cb0e16 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetManga.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetManga.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class GetManga @Inject constructor( private val mangaRepository: MangaRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetMangaFull.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetMangaFull.kt index 46cfb46d..d482a29f 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetMangaFull.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/GetMangaFull.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class GetMangaFull @Inject constructor( private val mangaRepository: MangaRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshManga.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshManga.kt index 21a59e1a..fee47a63 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshManga.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshManga.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class RefreshManga @Inject constructor( private val mangaRepository: MangaRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) @@ -40,11 +40,9 @@ class RefreshManga @Inject constructor( fun asFlow(mangaId: Long) = mangaRepository.getManga(mangaId, true).onEach { serverListeners.updateManga(mangaId) } - fun asFlow(manga: Manga) = mangaRepository.getManga(manga.id, true).onEach { serverListeners.updateManga(manga.id) } - companion object { private val log = logging() } diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshMangaFull.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshMangaFull.kt index 5e20e9ad..d56f119c 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshMangaFull.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/RefreshMangaFull.kt @@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging class RefreshMangaFull @Inject constructor( private val mangaRepository: MangaRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId) @@ -40,11 +40,9 @@ class RefreshMangaFull @Inject constructor( fun asFlow(mangaId: Long) = mangaRepository.getMangaFull(mangaId, true).onEach { serverListeners.updateManga(mangaId) } - fun asFlow(manga: Manga) = mangaRepository.getMangaFull(manga.id, true).onEach { serverListeners.updateManga(manga.id) } - companion object { private val log = logging() } diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/UpdateMangaMeta.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/UpdateMangaMeta.kt index 67d099aa..ee9ea737 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/UpdateMangaMeta.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/interactor/UpdateMangaMeta.kt @@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging class UpdateMangaMeta @Inject constructor( private val mangaRepository: MangaRepository, - private val serverListeners: ServerListeners, + private val serverListeners: ServerListeners ) { suspend fun await(