Introduce MatrixClient.rememberHideInvitesAvatar() extension to reduce code duplication.

This commit is contained in:
Benoit Marty 2025-09-10 15:33:59 +02:00 committed by Benoit Marty
parent c9bc7bf28a
commit 2128f3c059
5 changed files with 32 additions and 27 deletions

View file

@ -0,0 +1,24 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.matrix.ui.safety
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import io.element.android.libraries.core.coroutine.mapState
import io.element.android.libraries.matrix.api.MatrixClient
@Composable
fun MatrixClient.rememberHideInvitesAvatar(): State<Boolean> {
return remember {
mediaPreviewService()
.mediaPreviewConfigFlow
.mapState { config -> config.hideInviteAvatar }
}.collectAsState()
}