stop assuming that decryption happens ahead of time

pull/21833/head
Germain Souquet 2021-05-18 10:02:21 +01:00
parent 4929e3f3ed
commit 871c48f69b
5 changed files with 23 additions and 1 deletions

View File

@ -50,6 +50,10 @@ class FilePanel extends React.Component {
if (room?.roomId !== this.props?.roomId) return;
if (toStartOfTimeline || !data || !data.liveEvent || ev.isRedacted()) return;
if (ev.shouldAttemptDecryption()) {
ev.attemptDecryption(room._client._crypto);
}
if (ev.isBeingDecrypted()) {
this.decryptingEvents.add(ev.getId());
} else {

View File

@ -811,7 +811,7 @@ export default class RoomView extends React.Component<IProps, IState> {
};
private onEvent = (ev) => {
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
if (ev.isBeingDecrypted() || ev.isDecryptionFailure() || ev.shouldAttemptDecryption()) return;
this.handleEffects(ev);
};

View File

@ -31,6 +31,7 @@ import {RovingAccessibleTooltipButton, useRovingTabIndex} from "../../../accessi
import {replaceableComponent} from "../../../utils/replaceableComponent";
import {canCancel} from "../context_menus/MessageContextMenu";
import Resend from "../../../Resend";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
const OptionsButton = ({mxEvent, getTile, getReplyThread, permalinkCreator, onFocusChange}) => {
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
@ -122,6 +123,12 @@ export default class MessageActionBar extends React.PureComponent {
if (this.props.mxEvent.status && this.props.mxEvent.status !== EventStatus.SENT) {
this.props.mxEvent.on("Event.status", this.onSent);
}
if (this.props.mxEvent.shouldAttemptDecryption()) {
const client = MatrixClientPeg.get();
this.props.mxEvent.attemptDecryption(client._crypto);
}
if (this.props.mxEvent.isBeingDecrypted()) {
this.props.mxEvent.once("Event.decrypted", this.onDecrypted);
}

View File

@ -18,6 +18,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {replaceableComponent} from "../../../utils/replaceableComponent";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
@replaceableComponent("views.messages.ViewSourceEvent")
export default class ViewSourceEvent extends React.PureComponent {
@ -36,6 +37,12 @@ export default class ViewSourceEvent extends React.PureComponent {
componentDidMount() {
const {mxEvent} = this.props;
const client = MatrixClientPeg.get();
if (mxEvent.shouldAttemptDecryption()) {
mxEvent.attemptDecryption(client._client._crypto);
}
if (mxEvent.isBeingDecrypted()) {
mxEvent.once("Event.decrypted", () => this.forceUpdate());
}

View File

@ -187,6 +187,10 @@ export default class EventIndex extends EventEmitter {
return;
}
if (ev.shouldAttemptDecryption()) {
ev.attemptDecryption(room._client._crypto);
}
if (ev.isBeingDecrypted()) {
// XXX: Private member access
await ev._decryptionPromise;