From 148f64f53e8a3a3d5734a41d0ece1a60fa47d0b3 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Thu, 1 Feb 2024 12:40:40 +0530 Subject: [PATCH 1/3] Replace `images` list in `DynamicContentTheme` if all doesn't exists already Going back to previous check. We will keep the fetching outside so that it can happen after config changes as well. --- .../dev/sasikanth/rss/reader/components/DynamicContentTheme.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/components/DynamicContentTheme.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/components/DynamicContentTheme.kt index 3efa0f203..c71a17c20 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/components/DynamicContentTheme.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/components/DynamicContentTheme.kt @@ -260,7 +260,7 @@ internal class DynamicColorState( } suspend fun onContentChange(newImages: List) { - if (images.isEmpty()) { + if (!images.containsAll(newImages)) { images = newImages } images.forEach { imageUrl -> fetchDynamicColors(imageUrl) } @@ -272,7 +272,6 @@ internal class DynamicColorState( nextImageUrl: String?, offset: Float ) { - val previousDynamicColors = previousImageUrl?.let { cache?.get(it) } val currentDynamicColors = cache?.get(currentImageUrl) val nextDynamicColors = nextImageUrl?.let { cache?.get(it) } From 33f98fc592ce5ae85de6223e8ec16b40a6471c20 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Wed, 31 Jan 2024 06:44:33 +0530 Subject: [PATCH 2/3] Rename `feedLink` param name to `postLink` for `ReaderPresenterFactory` --- .../kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt index 43973d32e..69d32efb5 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt @@ -81,7 +81,7 @@ private typealias AboutPresenterFactory = private typealias ReaderPresenterFactory = ( - feedLink: String, + postLink: String, ComponentContext, goBack: () -> Unit, ) -> ReaderPresenter @@ -177,7 +177,7 @@ class AppPresenter( } is Config.Reader -> { Screen.Reader( - presenter = readerPresenter(config.feedLink, componentContext) { navigation.pop() } + presenter = readerPresenter(config.postLink, componentContext) { navigation.pop() } ) } } @@ -215,6 +215,6 @@ class AppPresenter( @Parcelize data object About : Config - @Parcelize data class Reader(val feedLink: String) : Config + @Parcelize data class Reader(val postLink: String) : Config } } From a1fd1fce0ceb658b182463acb7e34c929a9678b0 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Fri, 2 Feb 2024 17:36:31 +0530 Subject: [PATCH 3/3] Call `HomeScreen.Init` when `HomePresenterInstanse` class init happens (#273) I don't know why I decided to do it in on lifecycle on create. That ended up calling this `init` every time home screen presenter is created. Which means the paging cache is not used. Instead we are using the presenter instance class init to trigger subscribing to cached paging flow which fixes the scroll position getting reset of config changes. Weirdly it doesn't fix scroll position getting reset for navigation. Will have to check separately and resolve it in a different PR. --- .../kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt index 411b29ab8..5b75d37bc 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt @@ -104,7 +104,6 @@ class HomePresenter( init { lifecycle.doOnCreate { - presenterInstance.dispatch(HomeEvent.Init) backHandler.register(backCallback) backCallback.isEnabled = state.value.feedsSheetState == BottomSheetValue.Expanded } @@ -146,6 +145,10 @@ class HomePresenter( val effects = MutableSharedFlow() + init { + dispatch(HomeEvent.Init) + } + fun dispatch(event: HomeEvent) { when (event) { HomeEvent.Init -> init()