From 7ce2c0b1df235b40abd452a0b50eceb777424368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Saleniuk?= Date: Thu, 23 May 2024 14:34:37 +0200 Subject: [PATCH] fix: detekt --- .../android/ui/authentication/login/LoginScreen.kt | 11 ++++++++--- .../android/ui/authentication/login/LoginState.kt | 4 ++-- .../android/ui/authentication/login/LoginViewModel.kt | 2 -- .../authentication/login/email/LoginEmailViewModel.kt | 8 +++++--- .../ui/authentication/login/sso/LoginSSOViewModel.kt | 1 - .../android/ui/authentication/LoginViewModelTest.kt | 6 ------ 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginScreen.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginScreen.kt index bae9b732fe7..28063a2dfbc 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginScreen.kt @@ -105,7 +105,9 @@ fun LoginScreen( navigator.navigate(NavigationCommand(destination, BackStackMode.CLEAR_WHOLE)) }, - onRemoveDeviceNeeded = { navigator.navigate(NavigationCommand(RemoveDeviceScreenDestination, BackStackMode.CLEAR_WHOLE)) }, + onRemoveDeviceNeeded = { + navigator.navigate(NavigationCommand(RemoveDeviceScreenDestination, BackStackMode.CLEAR_WHOLE)) + }, loginEmailViewModel = loginEmailViewModel, ssoLoginResult = loginNavArgs.ssoLoginResult ) @@ -129,8 +131,11 @@ private fun LoginContent( targetState = loginEmailViewModel.secondFactorVerificationCodeState.isCodeInputNecessary, transitionSpec = { TransitionAnimationType.SLIDE.enterTransition.togetherWith(TransitionAnimationType.SLIDE.exitTransition) } ) { isCodeInputNecessary -> - if (isCodeInputNecessary) LoginEmailVerificationCodeScreen(loginEmailViewModel) - else MainLoginContent(onBackPressed, onSuccess, onRemoveDeviceNeeded, loginEmailViewModel, ssoLoginResult) + if (isCodeInputNecessary) { + LoginEmailVerificationCodeScreen(loginEmailViewModel) + } else { + MainLoginContent(onBackPressed, onSuccess, onRemoveDeviceNeeded, loginEmailViewModel, ssoLoginResult) + } } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt index d067486b887..a96243cccce 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt @@ -39,8 +39,8 @@ sealed class LoginState { data object PasswordNeededToRegisterClient : DialogError() data class SSOResultError(val result: SSOFailureCodes) : DialogError() - data object ServerVersionNotSupported: DialogError() - data object ClientUpdateRequired: DialogError() + data object ServerVersionNotSupported : DialogError() + data object ClientUpdateRequired : DialogError() } data object TooManyDevicesError : Error() } diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt index 408fbdfc18d..0750cd50fce 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt @@ -21,7 +21,6 @@ package com.wire.android.ui.authentication.login import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue -import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wire.android.BuildConfig @@ -46,7 +45,6 @@ import javax.inject.Inject @HiltViewModel @Suppress("TooManyFunctions") open class LoginViewModel @Inject constructor( - savedStateHandle: SavedStateHandle, private val clientScopeProviderFactory: ClientScopeProvider.Factory, protected val authServerConfigProvider: AuthServerConfigProvider, private val userDataStoreProvider: UserDataStoreProvider, diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt index a67104d0974..eedd8a7b86b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt @@ -70,7 +70,6 @@ class LoginEmailViewModel @Inject constructor( @KaliumCoreLogic coreLogic: CoreLogic, private val dispatchers: DispatcherProvider ) : LoginViewModel( - savedStateHandle, clientScopeProviderFactory, authServerConfigProvider, userDataStoreProvider, @@ -92,8 +91,11 @@ class LoginEmailViewModel @Inject constructor( init { userIdentifierTextState.setTextAndPlaceCursorAtEnd( - if (preFilledUserIdentifier is PreFilledUserIdentifierType.PreFilled) preFilledUserIdentifier.userIdentifier - else savedStateHandle[USER_IDENTIFIER_SAVED_STATE_KEY] ?: String.EMPTY + if (preFilledUserIdentifier is PreFilledUserIdentifierType.PreFilled) { + preFilledUserIdentifier.userIdentifier + } else { + savedStateHandle[USER_IDENTIFIER_SAVED_STATE_KEY] ?: String.EMPTY + } ) viewModelScope.launch { combine( diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt index 6b4f2339ff7..e8b1c513476 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt @@ -67,7 +67,6 @@ class LoginSSOViewModel @Inject constructor( authServerConfigProvider: AuthServerConfigProvider, userDataStoreProvider: UserDataStoreProvider ) : LoginViewModel( - savedStateHandle, clientScopeProviderFactory, authServerConfigProvider, userDataStoreProvider, diff --git a/app/src/test/kotlin/com/wire/android/ui/authentication/LoginViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/authentication/LoginViewModelTest.kt index f607f5ea503..e3ff2cd3d15 100644 --- a/app/src/test/kotlin/com/wire/android/ui/authentication/LoginViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/authentication/LoginViewModelTest.kt @@ -18,7 +18,6 @@ package com.wire.android.ui.authentication -import androidx.lifecycle.SavedStateHandle import com.wire.android.config.CoroutineTestExtension import com.wire.android.datastore.UserDataStoreProvider import com.wire.android.di.AuthServerConfigProvider @@ -42,9 +41,6 @@ class LoginViewModelTest { @MockK private lateinit var clientScopeProviderFactory: ClientScopeProvider.Factory - @MockK - private lateinit var savedStateHandle: SavedStateHandle - @MockK private lateinit var qualifiedIdMapper: QualifiedIdMapper @@ -62,11 +58,9 @@ class LoginViewModelTest { @BeforeEach fun setup() { MockKAnnotations.init(this) - every { savedStateHandle.get(any()) } returns null every { qualifiedIdMapper.fromStringToQualifiedID(any()) } returns QualifiedID("", "") every { authServerConfigProvider.authServer.value } returns newServerConfig(1).links loginViewModel = LoginViewModel( - savedStateHandle, clientScopeProviderFactory, authServerConfigProvider, userDataStoreProvider,