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