Remove or replace unnecessary BackHandler calls (#4148)

* Remove/replace `BackHandler` calls:

- For `UserProfileView`, remove the redundant `BackHandler` -> `navigateUp()` call.
- For `SetupBiometricView`, remove the `enabled = true` parameter, as this is the default value.
This commit is contained in:
Jorge Martin Espinosa 2025-01-15 10:43:26 +01:00 committed by GitHub
parent f31e648e35
commit a74a62c090
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 5 additions and 21 deletions

View file

@ -7,7 +7,6 @@
package io.element.android.features.userprofile.shared
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.consumeWindowInsets
@ -51,7 +50,6 @@ fun UserProfileView(
openAvatarPreview: (username: String, url: String) -> Unit,
modifier: Modifier = Modifier,
) {
BackHandler { goBack() }
Scaffold(
modifier = modifier,
topBar = {

View file

@ -34,7 +34,6 @@ import io.element.android.tests.testutils.ensureCalledOnce
import io.element.android.tests.testutils.ensureCalledOnceWithParam
import io.element.android.tests.testutils.ensureCalledOnceWithTwoParams
import io.element.android.tests.testutils.pressBack
import io.element.android.tests.testutils.pressBackKey
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
@ -46,16 +45,6 @@ import org.robolectric.annotation.Config
class UserProfileViewTest {
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
@Test
fun `on back key press - the expected callback is called`() = runTest {
ensureCalledOnce { callback ->
rule.setUserProfileView(
goBack = callback,
)
rule.pressBackKey()
}
}
@Test
fun `on back button click - the expected callback is called`() = runTest {
ensureCalledOnce { callback ->