Skip to content

Commit 9ac6fd5

Browse files
committed
compose box: Show error on sending message when not caught up.
Check if we are caught up in the current narrow, and if so, show an error when trying to send a message. This is similar to the webapp logic in [1]. [1] /static/js/echo.js:160 Fixes: zulip#3800
1 parent e044c7c commit 9ac6fd5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compose/ComposeBox.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
UserOrBot,
1515
Dispatch,
1616
Dimensions,
17+
CaughtUp,
1718
} from '../types';
1819
import { connect } from '../react-redux';
1920
import {
@@ -39,6 +40,7 @@ import {
3940
getSession,
4041
getLastMessageTopic,
4142
getActiveUsersByEmail,
43+
getCaughtUpForNarrow,
4244
} from '../selectors';
4345
import {
4446
getIsActiveStreamSubscribed,
@@ -59,6 +61,7 @@ type SelectorProps = {|
5961
isSubscribed: boolean,
6062
draft: string,
6163
lastMessageTopic: string,
64+
caughtUp: CaughtUp,
6265
|};
6366

6467
type Props = $ReadOnly<{|
@@ -242,9 +245,14 @@ class ComposeBox extends PureComponent<Props, State> {
242245
};
243246

244247
handleSend = () => {
245-
const { dispatch, narrow } = this.props;
248+
const { dispatch, narrow, caughtUp } = this.props;
246249
const { message } = this.state;
247250

251+
if (!caughtUp.newer) {
252+
showErrorAlert('Failed to send message', 'Error');
253+
return;
254+
}
255+
248256
dispatch(addToOutbox(this.getDestinationNarrow(), message));
249257

250258
this.setMessageInputValue('');
@@ -436,4 +444,5 @@ export default connect<SelectorProps, _, _>((state, props) => ({
436444
isSubscribed: getIsActiveStreamSubscribed(state, props.narrow),
437445
draft: getDraftForNarrow(state, props.narrow),
438446
lastMessageTopic: getLastMessageTopic(state, props.narrow),
447+
caughtUp: getCaughtUpForNarrow(state, props.narrow),
439448
}))(ComposeBox);

0 commit comments

Comments
 (0)