mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
Fix download button not working on events that were decrypted too late (#8556)
This commit is contained in:
parent
ad4d3f9a88
commit
a0c3a3ab06
1 changed files with 14 additions and 0 deletions
|
@ -20,6 +20,7 @@ import { Relations } from 'matrix-js-sdk/src/models/relations';
|
|||
import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon';
|
||||
import { M_LOCATION } from 'matrix-js-sdk/src/@types/location';
|
||||
import { M_POLL_START } from "matrix-events-sdk";
|
||||
import { MatrixEventEvent } from "matrix-js-sdk/src/models/event";
|
||||
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import { Mjolnir } from "../../../mjolnir/Mjolnir";
|
||||
|
@ -73,7 +74,12 @@ export default class MessageEvent extends React.Component<IProps> implements IMe
|
|||
}
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.props.mxEvent.addListener(MatrixEventEvent.Decrypted, this.onDecrypted);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
this.props.mxEvent.removeListener(MatrixEventEvent.Decrypted, this.onDecrypted);
|
||||
this.mediaHelper?.destroy();
|
||||
}
|
||||
|
||||
|
@ -118,6 +124,14 @@ export default class MessageEvent extends React.Component<IProps> implements IMe
|
|||
return this.mediaHelper;
|
||||
}
|
||||
|
||||
private onDecrypted = (): void => {
|
||||
// Recheck MediaEventHelper eligibility as it can change when the event gets decrypted
|
||||
if (MediaEventHelper.isEligible(this.props.mxEvent)) {
|
||||
this.mediaHelper?.destroy();
|
||||
this.mediaHelper = new MediaEventHelper(this.props.mxEvent);
|
||||
}
|
||||
};
|
||||
|
||||
private onTileUpdate = () => {
|
||||
this.forceUpdate();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue