diff --git a/resources/js/chat/input-box.tsx b/resources/js/chat/input-box.tsx index 181cf87316f..a71a4f990b0 100644 --- a/resources/js/chat/input-box.tsx +++ b/resources/js/chat/input-box.tsx @@ -24,7 +24,7 @@ export default class InputBox extends React.Component { private readonly inputBoxRef = React.createRef(); get allowMultiLine() { - return this.currentChannel?.type === 'ANNOUNCE'; + return this.isAnnouncement; } @computed @@ -37,6 +37,10 @@ export default class InputBox extends React.Component { return !this.currentChannel?.canMessage; } + get isAnnouncement() { + return this.currentChannel != null && this.currentChannel.type === 'ANNOUNCE'; + } + @computed get sendDisabled() { return this.inputDisabled || !core.dataStore.chatState.isReady; @@ -67,8 +71,7 @@ export default class InputBox extends React.Component { } buttonClicked = () => { - this.sendMessage(this.currentChannel?.inputText); - this.currentChannel?.setInputText(''); + this.startSendMessage(); }; checkIfEnterPressed = (e: React.KeyboardEvent) => { @@ -77,8 +80,7 @@ export default class InputBox extends React.Component { e.preventDefault(); if (!this.sendDisabled) { - this.sendMessage(this.currentChannel?.inputText); - this.currentChannel?.setInputText(''); + this.startSendMessage(); } } }; @@ -181,4 +183,13 @@ export default class InputBox extends React.Component { dispatch(new ChatMessageSendAction(message)); } + + @action + private readonly startSendMessage = () => { + if (this.isAnnouncement && !confirm(trans('common.confirmation'))) { + return; + } + this.sendMessage(this.currentChannel?.inputText); + this.currentChannel?.setInputText(''); + }; }