Merge pull request #651 from vector-im/feature/fga/refresh_can_send_event

CanSendEvent default to true and branch refresh
This commit is contained in:
Benoit Marty
2023-06-21 18:43:32 +02:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -88,7 +88,7 @@ class MessagesPresenter @Inject constructor(
val retryState = retrySendMenuPresenter.present()
val syncUpdateFlow = room.syncUpdateFlow().collectAsState(0L)
val userHasPermissionToSendMessage by room.canSendEventAsState(type = MessageEventType.ROOM_MESSAGE)
val userHasPermissionToSendMessage by room.canSendEventAsState(type = MessageEventType.ROOM_MESSAGE, updateKey = syncUpdateFlow.value)
val roomName: MutableState<String?> = rememberSaveable {
mutableStateOf(null)
}

View File

@@ -23,9 +23,9 @@ import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.api.room.MessageEventType
@Composable
fun MatrixRoom.canSendEventAsState(type: MessageEventType): State<Boolean> {
return produceState(initialValue = false, key1 = type) {
value = canSendEvent(type).getOrElse { false }
fun MatrixRoom.canSendEventAsState(type: MessageEventType, updateKey: Long): State<Boolean> {
return produceState(initialValue = true, key1 = updateKey) {
value = canSendEvent(type).getOrElse { true }
}
}