Skip to content

Commit 681cd15

Browse files
committed
Tidy up
1 parent b7a3d83 commit 681cd15

2 files changed

Lines changed: 14 additions & 24 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,11 +1296,9 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
12961296
const composerInsertPayload = payload as ComposerInsertPayload;
12971297
if (composerInsertPayload.composerType) break;
12981298

1299-
// If the dispatchee didn't request a timeline rendering type, use the current one.
1300-
let timelineRenderingType: TimelineRenderingType =
1301-
composerInsertPayload.timelineRenderingType ?? this.state.timelineRenderingType;
1299+
let timelineRenderingType: TimelineRenderingType | undefined;
13021300
// ThreadView handles Action.ComposerInsert itself due to it having its own editState
1303-
if (timelineRenderingType === TimelineRenderingType.Thread) break;
1301+
if (composerInsertPayload.timelineRenderingType === TimelineRenderingType.Thread) break;
13041302
if (
13051303
this.state.timelineRenderingType === TimelineRenderingType.Search &&
13061304
composerInsertPayload.timelineRenderingType === TimelineRenderingType.Search
@@ -1310,6 +1308,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
13101308
timelineRenderingType = TimelineRenderingType.Room;
13111309
}
13121310

1311+
// If the dispatchee didn't request a timeline rendering type, use the current one.
1312+
timelineRenderingType =
1313+
timelineRenderingType ??
1314+
composerInsertPayload.timelineRenderingType ??
1315+
this.state.timelineRenderingType;
1316+
13131317
// re-dispatch to the correct composer
13141318
defaultDispatcher.dispatch<ComposerInsertPayload>({
13151319
...composerInsertPayload,

apps/web/src/dispatcher/payloads/ComposerInsertPayload.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,18 @@ export enum ComposerType {
1515
Edit = "edit",
1616
}
1717

18-
/**
19-
* Explicit composer insert to target
20-
*/
21-
interface IBaseComposerInsertPayloadExplicit extends ActionPayload {
18+
interface IBaseComposerInsertPayload extends ActionPayload {
2219
action: Action.ComposerInsert;
23-
timelineRenderingType: TimelineRenderingType;
24-
composerType: ComposerType;
25-
}
26-
27-
/**
28-
* Explicit composer insert to current target.
29-
*/
30-
interface IBaseComposerInsertPayloadImplicit extends ActionPayload {
31-
action: Action.ComposerInsert;
32-
composerType?: undefined; // undefined if this should be re-dispatched to the correct composer
3320
timelineRenderingType?: TimelineRenderingType; // undefined if this should just use the current in-focus type.
21+
composerType?: ComposerType; // falsy if should be re-dispatched to the correct composer
3422
}
3523

36-
type IBaseComposerInsertPayload = IBaseComposerInsertPayloadExplicit | IBaseComposerInsertPayloadImplicit;
37-
38-
type IComposerInsertMentionPayload = IBaseComposerInsertPayload & {
24+
interface IComposerInsertMentionPayload extends IBaseComposerInsertPayload {
3925
userId: string;
40-
};
26+
}
4127

42-
type IComposerInsertPlaintextPayload = IBaseComposerInsertPayload & {
28+
interface IComposerInsertPlaintextPayload extends IBaseComposerInsertPayload {
4329
text: string;
44-
};
30+
}
4531

4632
export type ComposerInsertPayload = IComposerInsertMentionPayload | IComposerInsertPlaintextPayload;

0 commit comments

Comments
 (0)