Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "X kicked X" terminology when removing people from a room #4911

Merged
merged 4 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4865.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"/kick" command is replaced with "/remove"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also mention the replacement in the wordings.

Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ interface MembershipService {
/**
* Kick a user from the room
*/
suspend fun kick(userId: String, reason: String? = null)
suspend fun remove(userId: String, reason: String? = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also update the comment above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is a change in the SDK api, would be better to keep kick as an alias to remove and mark it as deprecated.
You can write in the interface something like:

@Deprecated("Use remove now")
suspend fun kick(userId: String, reason: String? = null) = remove(userId, reason)


/**
* Join the room, or accept an invitation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ internal class DefaultMembershipService @AssistedInject constructor(
membershipAdminTask.execute(params)
}

override suspend fun kick(userId: String, reason: String?) {
override suspend fun remove(userId: String, reason: String?) {
val params = MembershipAdminTask.Params(MembershipAdminTask.Type.KICK, roomId, userId, reason)
membershipAdminTask.execute(params)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AutocompleteCommandPresenter @Inject constructor(context: Context,
if (query.isNullOrEmpty()) {
true
} else {
it.command.startsWith(query, 1, true)
it.startsWith(query)
}
}
controller.setData(data)
Expand Down
78 changes: 41 additions & 37 deletions vector/src/main/java/im/vector/app/features/command/Command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,46 @@ import im.vector.app.R
* the user can write theses messages to perform some actions
* the list will be displayed in this order
*/
enum class Command(val command: String, val parameters: String, @StringRes val description: Int, val isDevCommand: Boolean) {
EMOTE("/me", "<message>", R.string.command_description_emote, false),
BAN_USER("/ban", "<user-id> [reason]", R.string.command_description_ban_user, false),
UNBAN_USER("/unban", "<user-id> [reason]", R.string.command_description_unban_user, false),
IGNORE_USER("/ignore", "<user-id> [reason]", R.string.command_description_ignore_user, false),
UNIGNORE_USER("/unignore", "<user-id>", R.string.command_description_unignore_user, false),
SET_USER_POWER_LEVEL("/op", "<user-id> [<power-level>]", R.string.command_description_op_user, false),
RESET_USER_POWER_LEVEL("/deop", "<user-id>", R.string.command_description_deop_user, false),
ROOM_NAME("/roomname", "<name>", R.string.command_description_room_name, false),
INVITE("/invite", "<user-id> [reason]", R.string.command_description_invite_user, false),
JOIN_ROOM("/join", "<room-address> [reason]", R.string.command_description_join_room, false),
PART("/part", "[<room-address>]", R.string.command_description_part_room, false),
TOPIC("/topic", "<topic>", R.string.command_description_topic, false),
KICK_USER("/kick", "<user-id> [reason]", R.string.command_description_kick_user, false),
CHANGE_DISPLAY_NAME("/nick", "<display-name>", R.string.command_description_nick, false),
CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "<display-name>", R.string.command_description_nick_for_room, false),
ROOM_AVATAR("/roomavatar", "<mxc_url>", R.string.command_description_room_avatar, true /* Since user has to know the mxc url */),
CHANGE_AVATAR_FOR_ROOM("/myroomavatar", "<mxc_url>", R.string.command_description_avatar_for_room, true /* Since user has to know the mxc url */),
MARKDOWN("/markdown", "<on|off>", R.string.command_description_markdown, false),
RAINBOW("/rainbow", "<message>", R.string.command_description_rainbow, false),
RAINBOW_EMOTE("/rainbowme", "<message>", R.string.command_description_rainbow_emote, false),
CLEAR_SCALAR_TOKEN("/clear_scalar_token", "", R.string.command_description_clear_scalar_token, false),
SPOILER("/spoiler", "<message>", R.string.command_description_spoiler, false),
SHRUG("/shrug", "<message>", R.string.command_description_shrug, false),
LENNY("/lenny", "<message>", R.string.command_description_lenny, false),
PLAIN("/plain", "<message>", R.string.command_description_plain, false),
WHOIS("/whois", "<user-id>", R.string.command_description_whois, false),
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session, false),
CONFETTI("/confetti", "<message>", R.string.command_confetti, false),
SNOWFALL("/snowfall", "<message>", R.string.command_snow, false),
CREATE_SPACE("/createspace", "<name> <invitee>*", R.string.command_description_create_space, true),
ADD_TO_SPACE("/addToSpace", "spaceId", R.string.command_description_add_to_space, true),
JOIN_SPACE("/joinSpace", "spaceId", R.string.command_description_join_space, true),
LEAVE_ROOM("/leave", "<roomId?>", R.string.command_description_leave_room, true),
UPGRADE_ROOM("/upgraderoom", "newVersion", R.string.command_description_upgrade_room, true);
enum class Command(val command: String, val aliases: Array<CharSequence>?, val parameters: String, @StringRes val description: Int, val isDevCommand: Boolean) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a strong opinion about it, but why using Array instead of List?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it because of spread operation used later here

val allAliases = arrayOf(command, *aliases.orEmpty())

EMOTE("/me", null, "<message>", R.string.command_description_emote, false),
BAN_USER("/ban", null, "<user-id> [reason]", R.string.command_description_ban_user, false),
UNBAN_USER("/unban", null, "<user-id> [reason]", R.string.command_description_unban_user, false),
IGNORE_USER("/ignore", null, "<user-id> [reason]", R.string.command_description_ignore_user, false),
UNIGNORE_USER("/unignore", null, "<user-id>", R.string.command_description_unignore_user, false),
SET_USER_POWER_LEVEL("/op", null, "<user-id> [<power-level>]", R.string.command_description_op_user, false),
RESET_USER_POWER_LEVEL("/deop", null, "<user-id>", R.string.command_description_deop_user, false),
ROOM_NAME("/roomname", null, "<name>", R.string.command_description_room_name, false),
INVITE("/invite", null, "<user-id> [reason]", R.string.command_description_invite_user, false),
JOIN_ROOM("/join", arrayOf("/j", "/goto"), "<room-address> [reason]", R.string.command_description_join_room, false),
PART("/part", null, "[<room-address>]", R.string.command_description_part_room, false),
TOPIC("/topic", null, "<topic>", R.string.command_description_topic, false),
REMOVE_USER("/remove", arrayOf("/kick"), "<user-id> [reason]", R.string.command_description_kick_user, false),
CHANGE_DISPLAY_NAME("/nick", null, "<display-name>", R.string.command_description_nick, false),
CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", arrayOf("/roomnick"), "<display-name>", R.string.command_description_nick_for_room, false),
ROOM_AVATAR("/roomavatar", null, "<mxc_url>", R.string.command_description_room_avatar, true /* Since user has to know the mxc url */),
CHANGE_AVATAR_FOR_ROOM("/myroomavatar", null, "<mxc_url>", R.string.command_description_avatar_for_room, true /* Since user has to know the mxc url */),
MARKDOWN("/markdown", null, "<on|off>", R.string.command_description_markdown, false),
RAINBOW("/rainbow", null, "<message>", R.string.command_description_rainbow, false),
RAINBOW_EMOTE("/rainbowme", null, "<message>", R.string.command_description_rainbow_emote, false),
CLEAR_SCALAR_TOKEN("/clear_scalar_token", null, "", R.string.command_description_clear_scalar_token, false),
SPOILER("/spoiler", null, "<message>", R.string.command_description_spoiler, false),
SHRUG("/shrug", null, "<message>", R.string.command_description_shrug, false),
LENNY("/lenny", null, "<message>", R.string.command_description_lenny, false),
PLAIN("/plain", null, "<message>", R.string.command_description_plain, false),
WHOIS("/whois", null, "<user-id>", R.string.command_description_whois, false),
DISCARD_SESSION("/discardsession", null, "", R.string.command_description_discard_session, false),
CONFETTI("/confetti", null, "<message>", R.string.command_confetti, false),
SNOWFALL("/snowfall", null, "<message>", R.string.command_snow, false),
CREATE_SPACE("/createspace", null, "<name> <invitee>*", R.string.command_description_create_space, true),
ADD_TO_SPACE("/addToSpace", null, "spaceId", R.string.command_description_add_to_space, true),
JOIN_SPACE("/joinSpace", null, "spaceId", R.string.command_description_join_space, true),
LEAVE_ROOM("/leave", null, "<roomId?>", R.string.command_description_leave_room, true),
UPGRADE_ROOM("/upgraderoom", null, "newVersion", R.string.command_description_upgrade_room, true);

val length
get() = command.length + 1
val allAliases = arrayOf(command, *aliases.orEmpty())

fun matches(inputCommand: CharSequence) = allAliases.any { it.contentEquals(inputCommand, true) }

fun startsWith(input: CharSequence) =
allAliases.any { it.startsWith(input, 1, true) }
}
Loading