Code review
This commit is contained in:
parent
301251262d
commit
4180b4ccd3
|
@ -157,4 +157,10 @@ object MatrixPatterns {
|
|||
fun isValidOrderString(order: String?) : Boolean {
|
||||
return order != null && order.length < 50 && order matches ORDER_STRING_REGEX
|
||||
}
|
||||
|
||||
fun candidateAliasFromRoomName(name: String): String {
|
||||
return Regex("\\s").replace(name.lowercase(), "_").let {
|
||||
"[^a-z0-9._%#@=+-]".toRegex().replace(it, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
* Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -35,6 +35,7 @@ import im.vector.app.core.platform.VectorViewModel
|
|||
import im.vector.app.core.resources.StringProvider
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.MatrixPatterns
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.room.AliasAvailabilityResult
|
||||
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
||||
|
@ -92,7 +93,6 @@ class CreateSpaceViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(CreateSpaceEvents.NavigateToDetails)
|
||||
}
|
||||
is CreateSpaceAction.NameChanged -> {
|
||||
|
||||
setState {
|
||||
if (aliasManuallyModified) {
|
||||
copy(
|
||||
|
@ -102,7 +102,7 @@ class CreateSpaceViewModel @AssistedInject constructor(
|
|||
)
|
||||
} else {
|
||||
val tentativeAlias =
|
||||
getAliasFromName(action.name)
|
||||
MatrixPatterns.candidateAliasFromRoomName(action.name)
|
||||
copy(
|
||||
nameInlineError = null,
|
||||
name = action.name,
|
||||
|
@ -157,12 +157,6 @@ class CreateSpaceViewModel @AssistedInject constructor(
|
|||
}.exhaustive
|
||||
}
|
||||
|
||||
private fun getAliasFromName(name: String): String {
|
||||
return Regex("\\s").replace(name.lowercase(), "_").let {
|
||||
"[^a-z0-9._%#@=+-]".toRegex().replace(it, "")
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSetTopology(action: CreateSpaceAction.SetSpaceTopology) {
|
||||
when (action.topology) {
|
||||
SpaceTopology.JustMe -> {
|
||||
|
|
|
@ -134,7 +134,7 @@ class SpaceSettingsController @Inject constructor(
|
|||
id = "manage_rooms",
|
||||
title = stringProvider.getString(R.string.space_settings_manage_rooms),
|
||||
// subtitle = data.getJoinRuleWording(stringProvider),
|
||||
divider = true,
|
||||
divider = vectorPreferences.developerMode() || isPublic,
|
||||
editable = data.actionPermissions.canAddChildren,
|
||||
action = {
|
||||
if (data.actionPermissions.canAddChildren) callback?.onManageRooms()
|
||||
|
@ -146,7 +146,7 @@ class SpaceSettingsController @Inject constructor(
|
|||
id = "alias",
|
||||
title = stringProvider.getString(R.string.space_settings_alias_title),
|
||||
subtitle = stringProvider.getString(R.string.space_settings_alias_subtitle),
|
||||
divider = true,
|
||||
divider = vectorPreferences.developerMode(),
|
||||
editable = true,
|
||||
action = { callback?.onRoomAliasesClicked() }
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue