@@ -35,7 +35,6 @@ import ContextMenu, {
3535} from "../../structures/ContextMenu" ;
3636import AccessibleTooltipButton from "../elements/AccessibleTooltipButton" ;
3737import ReplyPreview from "./ReplyPreview" ;
38- import { UIFeature } from "../../../settings/UIFeature" ;
3938import { UPDATE_EVENT } from "../../../stores/AsyncStore" ;
4039import { replaceableComponent } from "../../../utils/replaceableComponent" ;
4140import VoiceRecordComposerTile from "./VoiceRecordComposerTile" ;
@@ -56,6 +55,7 @@ import RoomContext from '../../../contexts/RoomContext';
5655import { POLL_START_EVENT_TYPE } from "../../../polls/consts" ;
5756import ErrorDialog from "../dialogs/ErrorDialog" ;
5857import PollCreateDialog from "../elements/PollCreateDialog" ;
58+ import { SettingUpdatedPayload } from "../../../dispatcher/payloads/SettingUpdatedPayload" ;
5959
6060let instanceCount = 0 ;
6161const NARROW_MODE_BREAKPOINT = 500 ;
@@ -249,6 +249,8 @@ interface IState {
249249 narrowMode ?: boolean ;
250250 isMenuOpen : boolean ;
251251 showStickers : boolean ;
252+ showStickersButton : boolean ;
253+ showPollsButton : boolean ;
252254}
253255
254256@replaceableComponent ( "views.rooms.MessageComposer" )
@@ -278,9 +280,14 @@ export default class MessageComposer extends React.Component<IProps, IState> {
278280 recordingTimeLeftSeconds : null , // when set to a number, shows a toast
279281 isMenuOpen : false ,
280282 showStickers : false ,
283+ showStickersButton : SettingsStore . getValue ( "MessageComposerInput.showStickersButton" ) ,
284+ showPollsButton : SettingsStore . getValue ( "feature_polls" ) ,
281285 } ;
282286
283287 this . instanceId = instanceCount ++ ;
288+
289+ SettingsStore . monitorSetting ( "MessageComposerInput.showStickersButton" , null ) ;
290+ SettingsStore . monitorSetting ( "feature_polls" , null ) ;
284291 }
285292
286293 componentDidMount ( ) {
@@ -303,14 +310,39 @@ export default class MessageComposer extends React.Component<IProps, IState> {
303310 } ;
304311
305312 private onAction = ( payload : ActionPayload ) => {
306- if ( payload . action === 'reply_to_event' && payload . context === this . context . timelineRenderingType ) {
307- // add a timeout for the reply preview to be rendered, so
308- // that the ScrollPanel listening to the resizeNotifier can
309- // correctly measure it's new height and scroll down to keep
310- // at the bottom if it already is
311- setTimeout ( ( ) => {
312- this . props . resizeNotifier . notifyTimelineHeightChanged ( ) ;
313- } , 100 ) ;
313+ switch ( payload . action ) {
314+ case "reply_to_event" :
315+ if ( payload . context === this . context . timelineRenderingType ) {
316+ // add a timeout for the reply preview to be rendered, so
317+ // that the ScrollPanel listening to the resizeNotifier can
318+ // correctly measure it's new height and scroll down to keep
319+ // at the bottom if it already is
320+ setTimeout ( ( ) => {
321+ this . props . resizeNotifier . notifyTimelineHeightChanged ( ) ;
322+ } , 100 ) ;
323+ }
324+ break ;
325+
326+ case Action . SettingUpdated : {
327+ const settingUpdatedPayload = payload as SettingUpdatedPayload ;
328+ switch ( settingUpdatedPayload . settingName ) {
329+ case "MessageComposerInput.showStickersButton" : {
330+ const showStickersButton = SettingsStore . getValue ( "MessageComposerInput.showStickersButton" ) ;
331+ if ( this . state . showStickersButton !== showStickersButton ) {
332+ this . setState ( { showStickersButton } ) ;
333+ }
334+ break ;
335+ }
336+
337+ case "feature_polls" : {
338+ const showPollsButton = SettingsStore . getValue ( "feature_polls" ) ;
339+ if ( this . state . showPollsButton !== showPollsButton ) {
340+ this . setState ( { showPollsButton } ) ;
341+ }
342+ break ;
343+ }
344+ }
345+ }
314346 }
315347 } ;
316348
@@ -452,9 +484,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
452484 } ;
453485
454486 private shouldShowStickerPicker = ( ) : boolean => {
455- return SettingsStore . getValue ( UIFeature . Widgets )
456- && SettingsStore . getValue ( "MessageComposerInput.showStickersButton" )
457- && ! this . state . haveRecording ;
487+ return this . state . showStickersButton && ! this . state . haveRecording ;
458488 } ;
459489
460490 private showStickers = ( showStickers : boolean ) => {
@@ -471,7 +501,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
471501 let uploadButtonIndex = 0 ;
472502 const buttons : JSX . Element [ ] = [ ] ;
473503 if ( ! this . state . haveRecording ) {
474- if ( SettingsStore . getValue ( "feature_polls" ) ) {
504+ if ( this . state . showPollsButton ) {
475505 buttons . push (
476506 < PollButton key = "polls" room = { this . props . room } /> ,
477507 ) ;
0 commit comments