mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Merge pull request #4763 from matrix-org/t3chguy/slash_cmd_ci
Fix case-sensitivity of /me to match rest of slash commands
This commit is contained in:
commit
68ca8b3891
3 changed files with 11 additions and 7 deletions
|
@ -118,7 +118,7 @@ export class Command {
|
||||||
|
|
||||||
run(roomId: string, args: string, cmd: string) {
|
run(roomId: string, args: string, cmd: string) {
|
||||||
// if it has no runFn then its an ignored/nop command (autocomplete only) e.g `/me`
|
// if it has no runFn then its an ignored/nop command (autocomplete only) e.g `/me`
|
||||||
if (!this.runFn) return;
|
if (!this.runFn) return reject(_t("Command error"));
|
||||||
return this.runFn.bind(this)(roomId, args, cmd);
|
return this.runFn.bind(this)(roomId, args, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,16 +62,20 @@ export function textSerialize(model: EditorModel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function containsEmote(model: EditorModel) {
|
export function containsEmote(model: EditorModel) {
|
||||||
return startsWith(model, "/me ");
|
return startsWith(model, "/me ", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startsWith(model: EditorModel, prefix: string) {
|
export function startsWith(model: EditorModel, prefix: string, caseSensitive = true) {
|
||||||
const firstPart = model.parts[0];
|
const firstPart = model.parts[0];
|
||||||
// part type will be "plain" while editing,
|
// part type will be "plain" while editing,
|
||||||
// and "command" while composing a message.
|
// and "command" while composing a message.
|
||||||
return firstPart &&
|
let text = firstPart && firstPart.text;
|
||||||
(firstPart.type === "plain" || firstPart.type === "command") &&
|
if (!caseSensitive) {
|
||||||
firstPart.text.startsWith(prefix);
|
prefix = prefix.toLowerCase();
|
||||||
|
text = text.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return firstPart && (firstPart.type === "plain" || firstPart.type === "command") && text.startsWith(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stripEmoteCommand(model: EditorModel) {
|
export function stripEmoteCommand(model: EditorModel) {
|
||||||
|
|
|
@ -148,6 +148,7 @@
|
||||||
"Actions": "Actions",
|
"Actions": "Actions",
|
||||||
"Advanced": "Advanced",
|
"Advanced": "Advanced",
|
||||||
"Other": "Other",
|
"Other": "Other",
|
||||||
|
"Command error": "Command error",
|
||||||
"Usage": "Usage",
|
"Usage": "Usage",
|
||||||
"Prepends ¯\\_(ツ)_/¯ to a plain-text message": "Prepends ¯\\_(ツ)_/¯ to a plain-text message",
|
"Prepends ¯\\_(ツ)_/¯ to a plain-text message": "Prepends ¯\\_(ツ)_/¯ to a plain-text message",
|
||||||
"Sends a message as plain text, without interpreting it as markdown": "Sends a message as plain text, without interpreting it as markdown",
|
"Sends a message as plain text, without interpreting it as markdown": "Sends a message as plain text, without interpreting it as markdown",
|
||||||
|
@ -1170,7 +1171,6 @@
|
||||||
"All Rooms": "All Rooms",
|
"All Rooms": "All Rooms",
|
||||||
"Search…": "Search…",
|
"Search…": "Search…",
|
||||||
"Server error": "Server error",
|
"Server error": "Server error",
|
||||||
"Command error": "Command error",
|
|
||||||
"Server unavailable, overloaded, or something else went wrong.": "Server unavailable, overloaded, or something else went wrong.",
|
"Server unavailable, overloaded, or something else went wrong.": "Server unavailable, overloaded, or something else went wrong.",
|
||||||
"Unknown Command": "Unknown Command",
|
"Unknown Command": "Unknown Command",
|
||||||
"Unrecognised command: %(commandText)s": "Unrecognised command: %(commandText)s",
|
"Unrecognised command: %(commandText)s": "Unrecognised command: %(commandText)s",
|
||||||
|
|
Loading…
Reference in a new issue