Browse Source

Hide blocked users list when there are no blocked users (#2504)

pull/2508/head
Jorge Martin Espinosa 7 months ago committed by GitHub
parent
commit
ee532c8b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      changelog.d/2198.bugfix
  2. 10
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt
  3. 1
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt
  4. 1
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt
  5. 12
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt

1
changelog.d/2198.bugfix

@ -0,0 +1 @@ @@ -0,0 +1 @@
Hide blocked users list when there are no blocked users.

10
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt

@ -22,6 +22,7 @@ import androidx.compose.runtime.MutableState @@ -22,6 +22,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import io.element.android.features.logout.api.direct.DirectLogoutPresenter
@ -39,6 +40,8 @@ import io.element.android.libraries.matrix.api.user.getCurrentUser @@ -39,6 +40,8 @@ import io.element.android.libraries.matrix.api.user.getCurrentUser
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
import io.element.android.services.analytics.api.AnalyticsService
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import javax.inject.Inject
@ -86,6 +89,12 @@ class PreferencesRootPresenter @Inject constructor( @@ -86,6 +89,12 @@ class PreferencesRootPresenter @Inject constructor(
mutableStateOf(null)
}
val showBlockedUsersItem by produceState(initialValue = false) {
matrixClient.ignoredUsersFlow
.onEach { value = it.isNotEmpty() }
.launchIn(this)
}
val directLogoutState = directLogoutPresenter.present()
LaunchedEffect(Unit) {
@ -106,6 +115,7 @@ class PreferencesRootPresenter @Inject constructor( @@ -106,6 +115,7 @@ class PreferencesRootPresenter @Inject constructor(
showDeveloperSettings = showDeveloperSettings,
showNotificationSettings = showNotificationSettings.value,
showLockScreenSettings = showLockScreenSettings.value,
showBlockedUsersItem = showBlockedUsersItem,
directLogoutState = directLogoutState,
snackbarMessage = snackbarMessage,
)

1
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt

@ -33,6 +33,7 @@ data class PreferencesRootState( @@ -33,6 +33,7 @@ data class PreferencesRootState(
val showDeveloperSettings: Boolean,
val showLockScreenSettings: Boolean,
val showNotificationSettings: Boolean,
val showBlockedUsersItem: Boolean,
val directLogoutState: DirectLogoutState,
val snackbarMessage: SnackbarMessage?,
)

1
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt

@ -33,6 +33,7 @@ fun aPreferencesRootState() = PreferencesRootState( @@ -33,6 +33,7 @@ fun aPreferencesRootState() = PreferencesRootState(
showDeveloperSettings = true,
showNotificationSettings = true,
showLockScreenSettings = true,
showBlockedUsersItem = true,
snackbarMessage = SnackbarMessage(CommonStrings.common_verification_complete),
directLogoutState = aDirectLogoutState(),
)

12
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt

@ -122,11 +122,13 @@ fun PreferencesRootView( @@ -122,11 +122,13 @@ fun PreferencesRootView(
onClick = onOpenNotificationSettings,
)
}
ListItem(
headlineContent = { Text(stringResource(id = CommonStrings.common_blocked_users)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
onClick = onOpenBlockedUsers,
)
if (state.showBlockedUsersItem) {
ListItem(
headlineContent = { Text(stringResource(id = CommonStrings.common_blocked_users)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
onClick = onOpenBlockedUsers,
)
}
ListItem(
headlineContent = { Text(stringResource(id = CommonStrings.common_report_a_problem)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.ChatProblem())),

Loading…
Cancel
Save