From 4b249156f9af56e99e95a6c44bda15fdfcb230d0 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 26 Aug 2024 18:22:34 -0400 Subject: [PATCH] Makes sure the accountViewModel is deleted when the user switches the screen, logs off or kills the activity. --- .../amethyst/ui/screen/AccountScreen.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountScreen.kt index 18d367de4..c2f604bb0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountScreen.kt @@ -102,6 +102,12 @@ fun AccountScreen( sharedPreferencesViewModel, ) } + + DisposableEffect(key1 = accountState) { + onDispose { + state.currentViewModelStore.viewModelStore.clear() + } + } } is AccountState.LoggedInViewOnly -> { CompositionLocalProvider( @@ -113,6 +119,12 @@ fun AccountScreen( sharedPreferencesViewModel, ) } + + DisposableEffect(key1 = accountState) { + onDispose { + state.currentViewModelStore.viewModelStore.clear() + } + } } } }