Render no buttons if we have a voice recording (#7658)

This commit is contained in:
Andy Balaam 2022-01-28 09:39:10 +00:00 committed by GitHub
parent 7fa27f5834
commit 15276ea3b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,7 +125,7 @@ class UploadButton extends React.Component<IUploadButtonProps> {
private uploadInput = React.createRef<HTMLInputElement>(); private uploadInput = React.createRef<HTMLInputElement>();
private dispatcherRef: string; private dispatcherRef: string;
constructor(props) { constructor(props: IUploadButtonProps) {
super(props); super(props);
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
@ -275,7 +275,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
compact: false, compact: false,
}; };
constructor(props) { constructor(props: IProps) {
super(props); super(props);
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate); VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
@ -499,10 +499,6 @@ export default class MessageComposer extends React.Component<IProps, IState> {
} }
}; };
private shouldShowStickerPicker = (): boolean => {
return this.state.showStickersButton && !this.state.haveRecording;
};
private showStickers = (showStickers: boolean) => { private showStickers = (showStickers: boolean) => {
this.setState({ showStickers }); this.setState({ showStickers });
}; };
@ -513,10 +509,13 @@ export default class MessageComposer extends React.Component<IProps, IState> {
}); });
}; };
private renderButtons(menuPosition): JSX.Element | JSX.Element[] { private renderButtons(menuPosition: AboveLeftOf): JSX.Element | JSX.Element[] {
if (this.state.haveRecording) {
return [];
}
let uploadButtonIndex = 0; let uploadButtonIndex = 0;
const buttons: JSX.Element[] = []; const buttons: JSX.Element[] = [];
if (!this.state.haveRecording) {
buttons.push( buttons.push(
<PollButton <PollButton
key="polls" key="polls"
@ -545,9 +544,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
buttons.push( buttons.push(
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} menuPosition={menuPosition} narrowMode={this.state.narrowMode} />, <EmojiButton key="emoji_button" addEmoji={this.addEmoji} menuPosition={menuPosition} narrowMode={this.state.narrowMode} />,
); );
} if (this.state.showStickersButton) {
if (this.shouldShowStickerPicker()) { let title: string;
let title;
if (!this.state.narrowMode) { if (!this.state.narrowMode) {
title = this.state.showStickers ? _t("Hide Stickers") : _t("Show Stickers"); title = this.state.showStickers ? _t("Hide Stickers") : _t("Show Stickers");
} }
@ -565,7 +563,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
} }
// XXX: the recording UI does not work well in narrow mode, so we hide this button for now // XXX: the recording UI does not work well in narrow mode, so we hide this button for now
if (!this.state.haveRecording && !this.state.narrowMode) { if (!this.state.narrowMode) {
buttons.push( buttons.push(
<CollapsibleButton <CollapsibleButton
key="voice_message_send" key="voice_message_send"