Merge pull request #5116 from matrix-org/t3chguy/cherry-pick/5115
[Release] Message Action Bar watch for event send changes
This commit is contained in:
commit
2eb48bc588
1 changed files with 15 additions and 3 deletions
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
import React, {useEffect} from 'react';
|
import React, {useEffect} from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { EventStatus } from 'matrix-js-sdk';
|
||||||
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import * as sdk from '../../../index';
|
import * as sdk from '../../../index';
|
||||||
|
@ -114,13 +115,19 @@ export default class MessageActionBar extends React.PureComponent {
|
||||||
static contextType = RoomContext;
|
static contextType = RoomContext;
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
|
if (this.props.mxEvent.status && this.props.mxEvent.status !== EventStatus.SENT) {
|
||||||
|
this.props.mxEvent.on("Event.status", this.onSent);
|
||||||
|
}
|
||||||
|
if (this.props.mxEvent.isBeingDecrypted()) {
|
||||||
|
this.props.mxEvent.once("Event.decrypted", this.onDecrypted);
|
||||||
|
}
|
||||||
this.props.mxEvent.on("Event.beforeRedaction", this.onBeforeRedaction);
|
this.props.mxEvent.on("Event.beforeRedaction", this.onBeforeRedaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.mxEvent.removeListener("Event.decrypted", this.onDecrypted);
|
this.props.mxEvent.off("Event.status", this.onSent);
|
||||||
this.props.mxEvent.removeListener("Event.beforeRedaction", this.onBeforeRedaction);
|
this.props.mxEvent.off("Event.decrypted", this.onDecrypted);
|
||||||
|
this.props.mxEvent.off("Event.beforeRedaction", this.onBeforeRedaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDecrypted = () => {
|
onDecrypted = () => {
|
||||||
|
@ -134,6 +141,11 @@ export default class MessageActionBar extends React.PureComponent {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onSent = () => {
|
||||||
|
// When an event is sent and echoed the possible actions change.
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
onFocusChange = (focused) => {
|
onFocusChange = (focused) => {
|
||||||
if (!this.props.onFocusChange) {
|
if (!this.props.onFocusChange) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue