From a530ced594ad7bd208a57fd5878ce28a8017f30c Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 1 Apr 2025 18:49:26 -0400 Subject: [PATCH] Performance: Avoids creating a SharedSettings ViewModel on Galery --- .../loggedIn/profile/gallery/ProfileGalleryFeed.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt index 4ab78a01a..a7d6c7c72 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/ProfileGalleryFeed.kt @@ -41,7 +41,6 @@ import com.vitorpamplona.amethyst.ui.feeds.FeedState import com.vitorpamplona.amethyst.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.ui.navigation.INav import com.vitorpamplona.amethyst.ui.screen.FeedViewModel -import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.FeedPadding @@ -89,14 +88,13 @@ private fun GalleryFeedLoaded( nav: INav, ) { val items by loaded.feed.collectAsStateWithLifecycle() - val sharedPreferencesViewModel: SharedPreferencesViewModel = viewModel() - sharedPreferencesViewModel.init() - - var ratio = 1.0f - if (sharedPreferencesViewModel.sharedPrefs.modernGalleryStyle.value) { - ratio = 0.8f - } + val ratio = + if (accountViewModel.settings.modernGalleryStyle.value) { + 0.8f + } else { + 1.0f + } LazyVerticalGrid( columns = GridCells.Fixed(3),