cancelling previous page jobs when switch gallery pages
This commit is contained in:
parent
2b9142b6c4
commit
ec56e74c98
|
@ -38,3 +38,8 @@ sealed interface PageAction : Action {
|
|||
data class PageContainer<P>(
|
||||
val page: SpiderPage<out P>
|
||||
)
|
||||
|
||||
fun PageContainer<*>.isDifferentPage(page: SpiderPage<*>): Boolean {
|
||||
return page::class != this.page::class
|
||||
}
|
||||
|
||||
|
|
|
@ -56,4 +56,10 @@ private fun SharedStateScope<Combined2<PageContainer<ImageGalleryPage>, Unit>>.c
|
|||
dispatch(PageAction.UpdatePage(page.state.copy(content = Lce.Content(media))))
|
||||
})
|
||||
},
|
||||
|
||||
sideEffect(PageAction.GoTo::class) { action, _ ->
|
||||
if (getSharedState().state1.isDifferentPage(action.page)) {
|
||||
jobBag.cancel("page")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue