Fix emoting with emoji or pills (#8105)

* Fix emoting with emoji or pills

* Fix some slash command errors not being shown

* Re-enable mistakenly skipped SendMessageComposer tests

* Test emoting with non-text parts
This commit is contained in:
Robin
2022-03-21 15:09:43 -04:00
committed by GitHub
parent 7a22682a80
commit 666cab954a
3 changed files with 19 additions and 5 deletions

View File

@@ -153,13 +153,11 @@ export class Command {
public run(roomId: string, threadId: string, args: string): RunResult {
// if it has no runFn then its an ignored/nop command (autocomplete only) e.g `/me`
if (!this.runFn) {
reject(
return reject(
newTranslatableError(
"Command error: Unable to handle slash command.",
),
);
return;
}
const renderingType = threadId

View File

@@ -181,7 +181,9 @@ export function textSerialize(model: EditorModel): string {
}
export function containsEmote(model: EditorModel): boolean {
return startsWith(model, "/me ", false) && model.parts[0]?.text?.length > 4;
const hasCommand = startsWith(model, "/me ", false);
const hasArgument = model.parts[0]?.text?.length > 4 || model.parts.length > 1;
return hasCommand && hasArgument;
}
export function startsWith(model: EditorModel, prefix: string, caseSensitive = true): boolean {