change (report room) : use client.isReportRoomApiSupported instead of hardcoded value

This commit is contained in:
ganfra 2025-05-13 16:20:37 +02:00
parent e6b1c196d6
commit 21f75db4bb
7 changed files with 25 additions and 9 deletions

View file

@ -23,7 +23,6 @@ import androidx.compose.runtime.setValue
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import im.vector.app.features.analytics.plan.JoinedRoom
import io.element.android.appconfig.MatrixConfiguration
import io.element.android.features.invite.api.SeenInvitesStore
import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteEvents
import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteState
@ -100,6 +99,8 @@ class JoinRoomPresenter @AssistedInject constructor(
val hideInviteAvatars by remember {
appPreferencesStore.getHideInviteAvatarsFlow()
}.collectAsState(initial = false)
val canReportRoom by produceState(false) { value = matrixClient.canReportRoom() }
val contentState by produceState<ContentState>(
initialValue = ContentState.Loading,
key1 = roomInfo,
@ -212,7 +213,7 @@ class JoinRoomPresenter @AssistedInject constructor(
applicationName = buildMeta.applicationName,
knockMessage = knockMessage,
hideInviteAvatars = hideInviteAvatars,
canReportRoom = MatrixConfiguration.CAN_REPORT_ROOM,
canReportRoom = canReportRoom,
eventSink = ::handleEvents
)
}

View file

@ -17,7 +17,6 @@ import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import im.vector.app.features.analytics.plan.Interaction
import io.element.android.appconfig.MatrixConfiguration
import io.element.android.features.leaveroom.api.LeaveRoomEvent
import io.element.android.features.leaveroom.api.LeaveRoomState
import io.element.android.features.messages.api.pinned.IsPinnedMessagesFeatureEnabled
@ -180,6 +179,8 @@ class RoomDetailsPresenter @Inject constructor(
.launchIn(this)
}
val canReportRoom by produceState(false) { value = client.canReportRoom() }
return RoomDetailsState(
roomId = room.roomId,
roomName = roomName,
@ -208,7 +209,7 @@ class RoomDetailsPresenter @Inject constructor(
knockRequestsCount = knockRequestsCount,
canShowSecurityAndPrivacy = canShowSecurityAndPrivacy,
hasMemberVerificationViolations = hasMemberVerificationViolations,
canReportRoom = MatrixConfiguration.CAN_REPORT_ROOM,
canReportRoom = canReportRoom,
eventSink = ::handleEvents,
)
}

View file

@ -23,7 +23,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import im.vector.app.features.analytics.plan.Interaction
import io.element.android.appconfig.MatrixConfiguration
import io.element.android.features.invite.api.SeenInvitesStore
import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteEvents.AcceptInvite
import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteEvents.DeclineInvite
@ -165,6 +164,8 @@ class RoomListPresenter @Inject constructor(
val contentState = roomListContentState(securityBannerDismissed)
val canReportRoom by produceState(false) { value = client.canReportRoom() }
return RoomListState(
matrixUser = matrixUser.value,
showAvatarIndicator = showAvatarIndicator,
@ -180,7 +181,7 @@ class RoomListPresenter @Inject constructor(
acceptDeclineInviteState = acceptDeclineInviteState,
directLogoutState = directLogoutState,
hideInvitesAvatars = hideInvitesAvatar,
canReportRoom = MatrixConfiguration.CAN_REPORT_ROOM,
canReportRoom = canReportRoom,
eventSink = ::handleEvents,
)
}