You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-03 00:33:22 +03:00
Chat Effects & Commands in thread context (#7138)
This commit is contained in:
@@ -57,6 +57,7 @@ import SlashCommandHelpDialog from "./components/views/dialogs/SlashCommandHelpD
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { shouldShowComponent } from "./customisations/helpers/UIComponents";
|
||||
import { TimelineRenderingType } from './contexts/RoomContext';
|
||||
|
||||
// XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816
|
||||
interface HTMLInputEvent extends Event {
|
||||
@@ -102,6 +103,7 @@ interface ICommandOpts {
|
||||
category: string;
|
||||
hideCompletionAfterSpace?: boolean;
|
||||
isEnabled?(): boolean;
|
||||
renderingTypes?: TimelineRenderingType[];
|
||||
}
|
||||
|
||||
export class Command {
|
||||
@@ -112,7 +114,8 @@ export class Command {
|
||||
runFn: undefined | RunFn;
|
||||
category: string;
|
||||
hideCompletionAfterSpace: boolean;
|
||||
_isEnabled?: () => boolean;
|
||||
private _isEnabled?: () => boolean;
|
||||
public renderingTypes?: TimelineRenderingType[];
|
||||
|
||||
constructor(opts: ICommandOpts) {
|
||||
this.command = opts.command;
|
||||
@@ -123,6 +126,7 @@ export class Command {
|
||||
this.category = opts.category || CommandCategories.other;
|
||||
this.hideCompletionAfterSpace = opts.hideCompletionAfterSpace || false;
|
||||
this._isEnabled = opts.isEnabled;
|
||||
this.renderingTypes = opts.renderingTypes;
|
||||
}
|
||||
|
||||
getCommand() {
|
||||
@@ -143,7 +147,7 @@ export class Command {
|
||||
return _t('Usage') + ': ' + this.getCommandWithArgs();
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
isEnabled(): boolean {
|
||||
return this._isEnabled ? this._isEnabled() : true;
|
||||
}
|
||||
}
|
||||
@@ -271,6 +275,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'nick',
|
||||
@@ -283,6 +288,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'myroomnick',
|
||||
@@ -302,6 +308,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'roomavatar',
|
||||
@@ -319,6 +326,7 @@ export const Commands = [
|
||||
}));
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'myroomavatar',
|
||||
@@ -345,6 +353,7 @@ export const Commands = [
|
||||
}));
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'myavatar',
|
||||
@@ -362,6 +371,7 @@ export const Commands = [
|
||||
}));
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'topic',
|
||||
@@ -387,6 +397,7 @@ export const Commands = [
|
||||
return success();
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'roomname',
|
||||
@@ -399,6 +410,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'invite',
|
||||
@@ -462,6 +474,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'join',
|
||||
@@ -577,6 +590,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'part',
|
||||
@@ -620,6 +634,7 @@ export const Commands = [
|
||||
return success(leaveRoomBehaviour(targetRoomId));
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'kick',
|
||||
@@ -635,6 +650,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'ban',
|
||||
@@ -650,6 +666,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'unban',
|
||||
@@ -666,6 +683,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'ignore',
|
||||
@@ -755,6 +773,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'deop',
|
||||
@@ -776,6 +795,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'devtools',
|
||||
@@ -838,6 +858,7 @@ export const Commands = [
|
||||
}
|
||||
},
|
||||
category: CommandCategories.admin,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'verify',
|
||||
@@ -903,6 +924,7 @@ export const Commands = [
|
||||
return reject(this.getUsage());
|
||||
},
|
||||
category: CommandCategories.advanced,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: 'discardsession',
|
||||
@@ -916,6 +938,7 @@ export const Commands = [
|
||||
return success();
|
||||
},
|
||||
category: CommandCategories.advanced,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: "rainbow",
|
||||
@@ -1053,6 +1076,7 @@ export const Commands = [
|
||||
call.setRemoteOnHold(true);
|
||||
return success();
|
||||
},
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: "unholdcall",
|
||||
@@ -1066,6 +1090,7 @@ export const Commands = [
|
||||
call.setRemoteOnHold(false);
|
||||
return success();
|
||||
},
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: "converttodm",
|
||||
@@ -1075,6 +1100,7 @@ export const Commands = [
|
||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||
return success(guessAndSetDMRoom(room, true));
|
||||
},
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
new Command({
|
||||
command: "converttoroom",
|
||||
@@ -1084,6 +1110,7 @@ export const Commands = [
|
||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||
return success(guessAndSetDMRoom(room, false));
|
||||
},
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
}),
|
||||
|
||||
// Command definitions for autocompletion ONLY:
|
||||
@@ -1117,6 +1144,7 @@ export const Commands = [
|
||||
})());
|
||||
},
|
||||
category: CommandCategories.effects,
|
||||
renderingTypes: [TimelineRenderingType.Room],
|
||||
});
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user