diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/AppScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/AppScreen.kt index e063818d8..acc04dd50 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/AppScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/AppScreen.kt @@ -26,7 +26,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.lifecycle.viewmodel.compose.viewModel import com.google.accompanist.adaptive.calculateDisplayFeatures -import com.vitorpamplona.amethyst.ServiceManager import com.vitorpamplona.amethyst.ui.screen.AccountScreen import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel @@ -56,13 +55,9 @@ fun prepareSharedViewModel(act: MainActivity): SharedPreferencesViewModel { } @Composable -fun AppScreen( - sharedPreferencesViewModel: SharedPreferencesViewModel, - serviceManager: ServiceManager, -) { +fun AppScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) { AmethystTheme(sharedPreferencesViewModel) { val accountStateViewModel: AccountStateViewModel = viewModel() - accountStateViewModel.serviceManager = serviceManager LaunchedEffect(key1 = Unit) { accountStateViewModel.tryLoginExistingAccountAsync() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt index 4fda7918f..ffe89ad63 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt @@ -78,7 +78,7 @@ class MainActivity : AppCompatActivity() { setContent { val sharedPreferencesViewModel = prepareSharedViewModel(act = this) - AppScreen(sharedPreferencesViewModel = sharedPreferencesViewModel, serviceManager = Amethyst.instance.serviceManager) + AppScreen(sharedPreferencesViewModel = sharedPreferencesViewModel) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt index 1fb58e771..a1343bc86 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt @@ -25,8 +25,8 @@ import androidx.compose.runtime.Stable import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.AccountInfo +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.LocalPreferences -import com.vitorpamplona.amethyst.ServiceManager import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.model.DefaultChannels import com.vitorpamplona.amethyst.model.DefaultDMRelayList @@ -66,8 +66,6 @@ val EMAIL_PATTERN = Pattern.compile(".+@.+\\.[a-z]+") @Stable class AccountStateViewModel : ViewModel() { - var serviceManager: ServiceManager? = null - private val _accountContent = MutableStateFlow(AccountState.Loading) val accountContent = _accountContent.asStateFlow() @@ -86,7 +84,7 @@ class AccountStateViewModel : ViewModel() { private suspend fun requestLoginUI() { _accountContent.update { AccountState.LoggedOff } - viewModelScope.launch(Dispatchers.IO) { serviceManager?.pauseForGoodAndClearAccount() } + viewModelScope.launch(Dispatchers.IO) { Amethyst.instance.serviceManager.pauseForGoodAndClearAccount() } } suspend fun loginAndStartUI(