@@ -52,6 +52,7 @@ import MessageComposerButtons from './MessageComposerButtons';
52
52
import { ButtonEvent } from '../elements/AccessibleButton' ;
53
53
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload" ;
54
54
import { isLocalRoom } from '../../../utils/localRoom/isLocalRoom' ;
55
+ import { Features } from '../../../settings/Settings' ;
55
56
56
57
let instanceCount = 0 ;
57
58
@@ -89,10 +90,11 @@ interface IState {
89
90
isStickerPickerOpen : boolean ;
90
91
showStickersButton : boolean ;
91
92
showPollsButton : boolean ;
93
+ showVoiceBroadcastButton : boolean ;
92
94
}
93
95
94
96
export default class MessageComposer extends React . Component < IProps , IState > {
95
- private dispatcherRef : string ;
97
+ private dispatcherRef ? : string ;
96
98
private messageComposerInput = createRef < SendMessageComposerClass > ( ) ;
97
99
private voiceRecordingButton = createRef < VoiceRecordComposerTile > ( ) ;
98
100
private ref : React . RefObject < HTMLDivElement > = createRef ( ) ;
@@ -114,17 +116,19 @@ export default class MessageComposer extends React.Component<IProps, IState> {
114
116
this . state = {
115
117
isComposerEmpty : true ,
116
118
haveRecording : false ,
117
- recordingTimeLeftSeconds : null , // when set to a number, shows a toast
119
+ recordingTimeLeftSeconds : undefined , // when set to a number, shows a toast
118
120
isMenuOpen : false ,
119
121
isStickerPickerOpen : false ,
120
122
showStickersButton : SettingsStore . getValue ( "MessageComposerInput.showStickersButton" ) ,
121
123
showPollsButton : SettingsStore . getValue ( "MessageComposerInput.showPollsButton" ) ,
124
+ showVoiceBroadcastButton : SettingsStore . getValue ( Features . VoiceBroadcast ) ,
122
125
} ;
123
126
124
127
this . instanceId = instanceCount ++ ;
125
128
126
129
SettingsStore . monitorSetting ( "MessageComposerInput.showStickersButton" , null ) ;
127
130
SettingsStore . monitorSetting ( "MessageComposerInput.showPollsButton" , null ) ;
131
+ SettingsStore . monitorSetting ( Features . VoiceBroadcast , null ) ;
128
132
}
129
133
130
134
private get voiceRecording ( ) : Optional < VoiceRecording > {
@@ -153,7 +157,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
153
157
public componentDidMount ( ) {
154
158
this . dispatcherRef = dis . register ( this . onAction ) ;
155
159
this . waitForOwnMember ( ) ;
156
- UIStore . instance . trackElementDimensions ( `MessageComposer${ this . instanceId } ` , this . ref . current ) ;
160
+ UIStore . instance . trackElementDimensions ( `MessageComposer${ this . instanceId } ` , this . ref . current ! ) ;
157
161
UIStore . instance . on ( `MessageComposer${ this . instanceId } ` , this . onResize ) ;
158
162
this . updateRecordingState ( ) ; // grab any cached recordings
159
163
}
@@ -199,13 +203,19 @@ export default class MessageComposer extends React.Component<IProps, IState> {
199
203
}
200
204
break ;
201
205
}
206
+ case Features . VoiceBroadcast : {
207
+ if ( this . state . showVoiceBroadcastButton !== settingUpdatedPayload . newValue ) {
208
+ this . setState ( { showVoiceBroadcastButton : ! ! settingUpdatedPayload . newValue } ) ;
209
+ }
210
+ break ;
211
+ }
202
212
}
203
213
}
204
214
}
205
215
} ;
206
216
207
217
private waitForOwnMember ( ) {
208
- // if we have the member already, do that
218
+ // If we have the member already, do that
209
219
const me = this . props . room . getMember ( MatrixClientPeg . get ( ) . getUserId ( ) ) ;
210
220
if ( me ) {
211
221
this . setState ( { me } ) ;
@@ -242,6 +252,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
242
252
}
243
253
244
254
const viaServers = [ this . context . tombstone . getSender ( ) . split ( ':' ) . slice ( 1 ) . join ( ':' ) ] ;
255
+
245
256
dis . dispatch < ViewRoomPayload > ( {
246
257
action : Action . ViewRoom ,
247
258
highlighted : true ,
@@ -426,8 +437,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
426
437
}
427
438
428
439
let recordingTooltip ;
429
- const secondsLeft = Math . round ( this . state . recordingTimeLeftSeconds ) ;
430
- if ( secondsLeft ) {
440
+ if ( this . state . recordingTimeLeftSeconds ) {
441
+ const secondsLeft = Math . round ( this . state . recordingTimeLeftSeconds ) ;
431
442
recordingTooltip = < Tooltip
432
443
label = { _t ( "%(seconds)ss left" , { seconds : secondsLeft } ) }
433
444
alignment = { Alignment . Top }
@@ -484,6 +495,14 @@ export default class MessageComposer extends React.Component<IProps, IState> {
484
495
showPollsButton = { this . state . showPollsButton }
485
496
showStickersButton = { this . showStickersButton }
486
497
toggleButtonMenu = { this . toggleButtonMenu }
498
+ showVoiceBroadcastButton = { this . state . showVoiceBroadcastButton }
499
+ onStartVoiceBroadcastClick = { ( ) => {
500
+ // Sends a voice message. To be replaced by voice broadcast during development.
501
+ this . voiceRecordingButton . current ?. onRecordStartEndClick ( ) ;
502
+ if ( this . context . narrow ) {
503
+ this . toggleButtonMenu ( ) ;
504
+ }
505
+ } }
487
506
/> }
488
507
{ showSendButton && (
489
508
< SendButton
0 commit comments