From 7dfbf3feb2f2f1eb9e9abda10abc98e67ddfd60d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Feb 2019 00:23:37 +0000 Subject: [PATCH] move canSendMessages into state so that it will re-render the composer Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/MessageComposer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index be6fbee4f6..83d4e2aa2e 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -68,6 +68,7 @@ export default class MessageComposer extends React.Component { showFormatting: SettingsStore.getValue('MessageComposer.showFormatting'), isQuoting: Boolean(RoomViewStore.getQuotingEvent()), tombstone: this._getRoomTombstone(), + canSendMessages: this.props.room.maySendMessage(), }; } @@ -120,6 +121,9 @@ export default class MessageComposer extends React.Component { if (ev.getType() === 'm.room.tombstone') { this.setState({tombstone: this._getRoomTombstone()}); } + if (ev.getType() === 'm.room.power_levels') { + this.setState({canSendMessages: this.props.room.maySendMessage()}); + } } _getRoomTombstone() { @@ -359,9 +363,6 @@ export default class MessageComposer extends React.Component { ; } - const canSendMessages = !this.state.tombstone && - this.props.room.maySendMessage(); - // TODO: Remove temporary logging for riot-web#7838 // Note: we rip apart the power level event ourselves because we don't want to // log too much data about it - just the bits we care about. Many of the variables @@ -390,7 +391,7 @@ export default class MessageComposer extends React.Component { ` myUserId=${room.myUserId} roomId=${room.roomId} hasPlEvent=${!!plEvent} powerLevels='${plEventString}'` ); - if (canSendMessages) { + if (!this.state.tombstone && this.state.canSendMessages) { // This also currently includes the call buttons. Really we should // check separately for whether we can call, but this is slightly // complex because of conference calls.