diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/source/interactor/SourcePager.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/source/interactor/SourcePager.kt index 4204ad69..3dac064c 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/source/interactor/SourcePager.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/source/interactor/SourcePager.kt @@ -25,13 +25,16 @@ import kotlinx.coroutines.flow.runningFold import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex +import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject import org.lighthousegames.logging.logging +typealias GetMangaPage = @param:Assisted suspend (page: Int) -> MangaPage? + class SourcePager @Inject constructor( private val getManga: GetManga, private val serverListeners: ServerListeners, - private val fetcher: suspend (page: Int) -> MangaPage? + private val fetcher: GetMangaPage ) : CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) { private val sourceMutex = Mutex() diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/SourceScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/SourceScreenViewModel.kt index c401454a..94c3a778 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/SourceScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/SourceScreenViewModel.kt @@ -9,6 +9,7 @@ package ca.gosyer.jui.ui.sources.browse import ca.gosyer.jui.domain.library.model.DisplayMode import ca.gosyer.jui.domain.library.service.LibraryPreferences import ca.gosyer.jui.domain.source.interactor.GetLatestManga +import ca.gosyer.jui.domain.source.interactor.GetMangaPage import ca.gosyer.jui.domain.source.interactor.GetPopularManga import ca.gosyer.jui.domain.source.interactor.GetSearchManga import ca.gosyer.jui.domain.source.interactor.SourcePager @@ -38,7 +39,7 @@ class SourceScreenViewModel( private val getSearchManga: GetSearchManga, private val catalogPreferences: CatalogPreferences, private val libraryPreferences: LibraryPreferences, - private val getSourcePager: (suspend (page: Int) -> MangaPage?) -> SourcePager, + private val getSourcePager: (GetMangaPage) -> SourcePager, contextWrapper: ContextWrapper, private val savedStateHandle: SavedStateHandle, initialQuery: String? @@ -50,7 +51,7 @@ class SourceScreenViewModel( getSearchManga: GetSearchManga, catalogPreferences: CatalogPreferences, libraryPreferences: LibraryPreferences, - getSourcePager: (suspend (page: Int) -> MangaPage?) -> SourcePager, + getSourcePager: (GetMangaPage) -> SourcePager, contextWrapper: ContextWrapper, @Assisted savedStateHandle: SavedStateHandle, @Assisted params: Params