diff --git a/features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducer.kt b/features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducer.kt index 138851f..db75035 100644 --- a/features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducer.kt +++ b/features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducer.kt @@ -57,7 +57,7 @@ fun imageGalleryReducer( }, sideEffect(PageStateChange.ChangePage::class) { action, _ -> - jobBag.cancel(action.previous::class) + jobBag.cancel(action.previous.state::class) }, ) } diff --git a/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt b/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt index 49fbe18..bb684b1 100644 --- a/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt +++ b/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt @@ -90,6 +90,14 @@ class ImageGalleryReducerTest { ) } + @Test + fun `when ChangePage, then cancels previous page jobs`() = runReducerTest { + fakeJobBag.instance.expect { it.cancel(ImageGalleryPage.Folders::class) } + + reduce(PageStateChange.ChangePage(previous = AN_INITIAL_FOLDERS_PAGE, newPage = AN_INITIAL_FILES_PAGE)) + + assertOnlyStateChange(pageState(AN_INITIAL_FILES_PAGE)) + } } private fun

pageState(page: SpiderPage) = Combined2(PageContainer(page), Unit)