Skip to content

Commit c6e6a30

Browse files
committed
cleanup
1 parent 5b9f885 commit c6e6a30

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

apps/web/src/components/structures/ThreadView.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,15 @@ export default class ThreadView extends React.Component<IProps, IState> {
167167
}
168168
switch (payload.action) {
169169
case Action.ComposerInsert: {
170-
if (payload.composerType) break;
171-
if (payload.timelineRenderingType !== TimelineRenderingType.Thread) break;
170+
const insertPayload = payload as ComposerInsertPayload;
171+
const timelineRenderingType = insertPayload.timelineRenderingType;
172+
if (insertPayload.composerType) break;
173+
if (timelineRenderingType !== TimelineRenderingType.Thread) break;
172174

173175
// re-dispatch to the correct composer
174176
dis.dispatch<ComposerInsertPayload>({
175-
...(payload as ComposerInsertPayload),
177+
...insertPayload,
178+
timelineRenderingType,
176179
composerType: this.state.editState ? ComposerType.Edit : ComposerType.Send,
177180
});
178181
break;

apps/web/test/unit-tests/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,10 @@ describe("EditWysiwygComposer", () => {
283283
// It adds the composerType fields where the value refers if the composer is in editing or not
284284
// The listeners in the RTE ignore the message if the composerType is missing in the payload
285285
const dispatcherRef = defaultDispatcher.register((payload: ActionPayload) => {
286+
const insertPayload = payload as ComposerInsertPayload;
286287
defaultDispatcher.dispatch<ComposerInsertPayload>({
287-
...(payload as ComposerInsertPayload),
288+
...insertPayload,
289+
timelineRenderingType: insertPayload.timelineRenderingType!,
288290
composerType: ComposerType.Edit,
289291
});
290292
});

apps/web/test/unit-tests/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ describe("SendWysiwygComposer", () => {
4848
const registerId = defaultDispatcher.register((payload) => {
4949
switch (payload.action) {
5050
case Action.ComposerInsert: {
51-
if (payload.composerType) break;
51+
const insertPayload = payload as ComposerInsertPayload;
52+
if (insertPayload.composerType) break;
5253

5354
// re-dispatch to the correct composer
5455
defaultDispatcher.dispatch<ComposerInsertPayload>({
55-
...(payload as ComposerInsertPayload),
56+
...insertPayload,
57+
timelineRenderingType: insertPayload.timelineRenderingType!,
5658
composerType: ComposerType.Send,
5759
});
5860
break;

packages/module-api/element-web-module-api.api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiEx
4747
// @alpha
4848
readonly builtins: BuiltinsApi;
4949
readonly client: ClientApi;
50-
// Warning: (ae-forgotten-export) The symbol "ComposerApi" needs to be exported by the entry point index.d.ts
51-
//
5250
// @alpha
5351
readonly composer: ComposerApi;
5452
readonly config: ConfigApi;
@@ -101,6 +99,11 @@ export interface ComponentVisibilityCustomisations {
10199
shouldShowComponent?(component: "UIComponent.sendInvites" | "UIComponent.roomCreation" | "UIComponent.spaceCreation" | "UIComponent.exploreRooms" | "UIComponent.addIntegrations" | "UIComponent.filterContainer" | "UIComponent.roomOptionsMenu"): boolean;
102100
}
103101

102+
// @alpha
103+
export interface ComposerApi {
104+
insertTextIntoComposer(text: string): void;
105+
}
106+
104107
// @public
105108
export interface Config {
106109
// (undocumented)

packages/module-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type { Config, ConfigApi } from "./api/config";
1111
export type { I18nApi, Variables, Translations, SubstitutionValue, Tags } from "./api/i18n";
1212
export type * from "./models/event";
1313
export type * from "./models/Room";
14+
export type * from "./api/composer";
1415
export type * from "./api/custom-components";
1516
export type * from "./api/extras";
1617
export type * from "./api/legacy-modules";

0 commit comments

Comments
 (0)