@@ -30,7 +30,7 @@ import { connect } from '../react-redux';
30
30
import { withGetText } from '../boot/TranslationProvider' ;
31
31
import { draftUpdate , sendTypingStart , sendTypingStop } from '../actions' ;
32
32
import { FloatingActionButton , Input } from '../common' ;
33
- import { showToast } from '../utils/info' ;
33
+ import { showToast , showErrorAlert } from '../utils/info' ;
34
34
import { IconDone , IconSend } from '../common/Icons' ;
35
35
import {
36
36
isConversationNarrow ,
@@ -46,7 +46,13 @@ import getComposeInputPlaceholder from './getComposeInputPlaceholder';
46
46
import NotSubscribed from '../message/NotSubscribed' ;
47
47
import AnnouncementOnly from '../message/AnnouncementOnly' ;
48
48
import MentionWarnings from './MentionWarnings' ;
49
- import { getAuth , getIsAdmin , getStreamInNarrow , getVideoChatProvider } from '../selectors' ;
49
+ import {
50
+ getAuth ,
51
+ getIsAdmin ,
52
+ getStreamInNarrow ,
53
+ getVideoChatProvider ,
54
+ getRealm ,
55
+ } from '../selectors' ;
50
56
import {
51
57
getIsActiveStreamSubscribed ,
52
58
getIsActiveStreamAnnouncementOnly ,
@@ -64,6 +70,7 @@ type SelectorProps = {|
64
70
isAnnouncementOnly : boolean ,
65
71
isSubscribed : boolean ,
66
72
videoChatProvider : VideoChatProvider | null ,
73
+ mandatoryTopics : boolean ,
67
74
stream : Subscription | { | ...Stream , in_home_view : boolean | } ,
68
75
| } ;
69
76
@@ -401,10 +408,21 @@ class ComposeBoxInner extends PureComponent<Props, State> {
401
408
} ;
402
409
403
410
handleSend = ( ) => {
404
- const { dispatch } = this . props ;
411
+ const { dispatch, mandatoryTopics , _ } = this . props ;
405
412
const { message } = this . state ;
406
413
const destinationNarrow = this . getDestinationNarrow ( ) ;
407
414
415
+ if (
416
+ isTopicNarrow ( destinationNarrow )
417
+ && topicOfNarrow ( destinationNarrow ) === apiConstants . NO_TOPIC_TOPIC
418
+ && mandatoryTopics
419
+ ) {
420
+ // TODO how should this behave in the isEditing case? See
421
+ // https://github.com/zulip/zulip-mobile/pull/4798#discussion_r731341400.
422
+ showErrorAlert ( _ ( 'Message not sent' ) , _ ( 'Please specify a topic.' ) ) ;
423
+ return ;
424
+ }
425
+
408
426
this . props . onSend ( message , destinationNarrow ) ;
409
427
410
428
this . setMessageInputValue ( '' ) ;
@@ -588,6 +606,7 @@ const ComposeBox: ComponentType<OuterProps> = compose(
588
606
isSubscribed : getIsActiveStreamSubscribed ( state , props . narrow ) ,
589
607
stream : getStreamInNarrow ( state , props . narrow ) ,
590
608
videoChatProvider : getVideoChatProvider ( state ) ,
609
+ mandatoryTopics : getRealm ( state ) . mandatoryTopics ,
591
610
} )),
592
611
withSafeAreaInsets,
593
612
)(withGetText(ComposeBoxInner));
0 commit comments