create room : use user homeserver in the address field.

This commit is contained in:
ganfra
2024-10-29 16:54:09 +01:00
parent 4582acd536
commit c968bc6200
4 changed files with 7 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ class ConfigureRoomPresenter @Inject constructor(
override fun present(): ConfigureRoomState {
val cameraPermissionState = cameraPermissionPresenter.present()
val createRoomConfig = dataStore.createRoomConfig.collectAsState(CreateRoomConfig())
val homeserverName = remember { matrixClient.userIdServerName() }
val cameraPhotoPicker = mediaPickerProvider.registerCameraPhotoPicker(
onResult = { uri -> if (uri != null) dataStore.setAvatarUri(uri = uri, cached = true) },
@@ -120,6 +121,7 @@ class ConfigureRoomPresenter @Inject constructor(
avatarActions = avatarActions,
createRoomAction = createRoomAction.value,
cameraPermissionState = cameraPermissionState,
homeserverName = homeserverName,
eventSink = ::handleEvents,
)
}

View File

@@ -19,6 +19,7 @@ data class ConfigureRoomState(
val avatarActions: ImmutableList<AvatarAction>,
val createRoomAction: AsyncAction<RoomId>,
val cameraPermissionState: PermissionsState,
val homeserverName: String,
val eventSink: (ConfigureRoomEvents) -> Unit
) {
val isCreateButtonEnabled: Boolean = config.roomName.isNullOrEmpty().not()

View File

@@ -38,5 +38,6 @@ fun aConfigureRoomState() = ConfigureRoomState(
avatarActions = persistentListOf(),
createRoomAction = AsyncAction.Uninitialized,
cameraPermissionState = aPermissionsState(showDialog = false),
homeserverName = "matrix.org",
eventSink = { },
)

View File

@@ -141,6 +141,7 @@ fun ConfigureRoomView(
RoomAddress(
modifier = Modifier.padding(horizontal = 16.dp),
address = state.config.roomVisibility.roomAddress,
homeserverName = state.homeserverName,
onAddressChange = { state.eventSink(ConfigureRoomEvents.RoomAddressChanged(it)) },
)
}
@@ -311,6 +312,7 @@ private fun RoomAccessOptions(
@Composable
private fun RoomAddress(
address: RoomAddress,
homeserverName: String,
onAddressChange: (String) -> Unit,
modifier: Modifier = Modifier,
) {
@@ -340,7 +342,7 @@ private fun RoomAddress(
},
trailingIcon = {
Text(
text = ":myserver.com",
text = homeserverName,
style = ElementTheme.typography.fontBodyLgMedium,
color = ElementTheme.colors.textSecondary,
modifier = Modifier.padding(end = 16.dp)