@@ -95,7 +95,7 @@ type State = {|
95
95
isFocused : boolean ,
96
96
97
97
isMenuExpanded : boolean ,
98
- topic : string ,
98
+ topic : ? string ,
99
99
message : string ,
100
100
height : number ,
101
101
selection : InputSelection ,
@@ -144,13 +144,21 @@ class ComposeBox extends PureComponent<Props, State> {
144
144
145
145
inputBlurTimeoutId : ?TimeoutID = null ;
146
146
147
+ getCanSelectTopic = ( ) = > {
148
+ const { editMessage, narrow } = this . props ;
149
+ if ( editMessage ) {
150
+ return isStreamOrTopicNarrow ( narrow ) ;
151
+ }
152
+ return isStreamNarrow ( narrow ) ;
153
+ } ;
154
+
147
155
state = {
148
156
isMessageFocused : false ,
149
157
isTopicFocused : false ,
150
158
isFocused : false ,
151
159
isMenuExpanded : false ,
152
160
height : 20 ,
153
- topic : '' ,
161
+ topic : this . getCanSelectTopic ( ) ? '' : null ,
154
162
message : this . props . draft ,
155
163
selection : { start : 0 , end : 0 } ,
156
164
} ;
@@ -167,14 +175,6 @@ class ComposeBox extends PureComponent<Props, State> {
167
175
} ) ) ;
168
176
} ;
169
177
170
- getCanSelectTopic = ( ) => {
171
- const { editMessage, narrow } = this . props ;
172
- if ( editMessage ) {
173
- return isStreamOrTopicNarrow ( narrow ) ;
174
- }
175
- return isStreamNarrow ( narrow ) ;
176
- } ;
177
-
178
178
setMessageInputValue = ( message : string ) = > {
179
179
updateTextInput ( this . messageInputRef . current , message ) ;
180
180
this . handleMessageChange ( message ) ;
@@ -304,10 +304,10 @@ class ComposeBox extends PureComponent<Props, State> {
304
304
305
305
getDestinationNarrow = ( ) : Narrow => {
306
306
const { narrow } = this . props ;
307
- if ( isStreamNarrow ( narrow ) ) {
307
+ const topic = this . state . topic ;
308
+ if ( isStreamNarrow ( narrow ) && topic != null ) {
308
309
const streamName = streamNameOfNarrow ( narrow ) ;
309
- const topic = this . state . topic . trim ( ) ;
310
- return topicNarrow ( streamName , topic || '(no topic)' ) ;
310
+ return topicNarrow ( streamName , topic . trim ( ) || '(no topic)' ) ;
311
311
}
312
312
return narrow ;
313
313
} ;
@@ -339,7 +339,7 @@ class ComposeBox extends PureComponent<Props, State> {
339
339
}
340
340
const { message , topic } = this . state ;
341
341
const content = editMessage . content !== message ? message : undefined ;
342
- const subject = topic !== editMessage . topic ? topic : undefined ;
342
+ const subject = topic !== editMessage . topic && topic != null ? topic : undefined ;
343
343
if ( ( content !== undefined && content !== '' ) || ( subject !== undefined && subject !== '' ) ) {
344
344
api . updateMessage ( auth , { content, subject } , editMessage . id ) . catch ( error => {
345
345
showErrorAlert ( _ ( 'Failed to edit message' ) , error . message ) ;
@@ -448,12 +448,14 @@ class ComposeBox extends PureComponent<Props, State> {
448
448
*/ }
449
449
< MentionWarnings narrow = { narrow } stream = { stream } ref = { this . mentionWarnings } />
450
450
< View style = { [ this . styles . autocompleteWrapper , { marginBottom : height } ] } >
451
- < TopicAutocomplete
452
- isFocused = { isTopicFocused }
453
- narrow = { narrow }
454
- text = { topic }
455
- onAutocomplete = { this . handleTopicAutocomplete }
456
- />
451
+ { topic != null && (
452
+ < TopicAutocomplete
453
+ isFocused = { isTopicFocused }
454
+ narrow = { narrow }
455
+ text = { topic }
456
+ onAutocomplete = { this . handleTopicAutocomplete }
457
+ />
458
+ ) }
457
459
< AutocompleteView
458
460
isFocused = { this . state . isMessageFocused }
459
461
selection = { selection }
0 commit comments