Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 15276ea

Browse files
authored
Render no buttons if we have a voice recording (#7658)
1 parent 7fa27f5 commit 15276ea

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

src/components/views/rooms/MessageComposer.tsx

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class UploadButton extends React.Component<IUploadButtonProps> {
125125
private uploadInput = React.createRef<HTMLInputElement>();
126126
private dispatcherRef: string;
127127

128-
constructor(props) {
128+
constructor(props: IUploadButtonProps) {
129129
super(props);
130130

131131
this.dispatcherRef = dis.register(this.onAction);
@@ -275,7 +275,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
275275
compact: false,
276276
};
277277

278-
constructor(props) {
278+
constructor(props: IProps) {
279279
super(props);
280280
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
281281

@@ -499,10 +499,6 @@ export default class MessageComposer extends React.Component<IProps, IState> {
499499
}
500500
};
501501

502-
private shouldShowStickerPicker = (): boolean => {
503-
return this.state.showStickersButton && !this.state.haveRecording;
504-
};
505-
506502
private showStickers = (showStickers: boolean) => {
507503
this.setState({ showStickers });
508504
};
@@ -513,41 +509,43 @@ export default class MessageComposer extends React.Component<IProps, IState> {
513509
});
514510
};
515511

516-
private renderButtons(menuPosition): JSX.Element | JSX.Element[] {
512+
private renderButtons(menuPosition: AboveLeftOf): JSX.Element | JSX.Element[] {
513+
if (this.state.haveRecording) {
514+
return [];
515+
}
516+
517517
let uploadButtonIndex = 0;
518518
const buttons: JSX.Element[] = [];
519-
if (!this.state.haveRecording) {
519+
buttons.push(
520+
<PollButton
521+
key="polls"
522+
room={this.props.room}
523+
narrowMode={this.state.narrowMode}
524+
/>,
525+
);
526+
uploadButtonIndex = buttons.length;
527+
buttons.push(
528+
<UploadButton key="controls_upload" roomId={this.props.room.roomId} relation={this.props.relation} />,
529+
);
530+
if (this.state.showLocationButton) {
531+
const sender = this.props.room.getMember(
532+
MatrixClientPeg.get().getUserId(),
533+
);
520534
buttons.push(
521-
<PollButton
522-
key="polls"
523-
room={this.props.room}
535+
<LocationButton
536+
key="location"
537+
roomId={this.props.room.roomId}
538+
sender={sender}
539+
menuPosition={menuPosition}
524540
narrowMode={this.state.narrowMode}
525541
/>,
526542
);
527-
uploadButtonIndex = buttons.length;
528-
buttons.push(
529-
<UploadButton key="controls_upload" roomId={this.props.room.roomId} relation={this.props.relation} />,
530-
);
531-
if (this.state.showLocationButton) {
532-
const sender = this.props.room.getMember(
533-
MatrixClientPeg.get().getUserId(),
534-
);
535-
buttons.push(
536-
<LocationButton
537-
key="location"
538-
roomId={this.props.room.roomId}
539-
sender={sender}
540-
menuPosition={menuPosition}
541-
narrowMode={this.state.narrowMode}
542-
/>,
543-
);
544-
}
545-
buttons.push(
546-
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} menuPosition={menuPosition} narrowMode={this.state.narrowMode} />,
547-
);
548543
}
549-
if (this.shouldShowStickerPicker()) {
550-
let title;
544+
buttons.push(
545+
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} menuPosition={menuPosition} narrowMode={this.state.narrowMode} />,
546+
);
547+
if (this.state.showStickersButton) {
548+
let title: string;
551549
if (!this.state.narrowMode) {
552550
title = this.state.showStickers ? _t("Hide Stickers") : _t("Show Stickers");
553551
}
@@ -565,7 +563,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
565563
}
566564

567565
// XXX: the recording UI does not work well in narrow mode, so we hide this button for now
568-
if (!this.state.haveRecording && !this.state.narrowMode) {
566+
if (!this.state.narrowMode) {
569567
buttons.push(
570568
<CollapsibleButton
571569
key="voice_message_send"

0 commit comments

Comments
 (0)