Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a0c3a3a

Browse files
Fix download button not working on events that were decrypted too late (#8556)
1 parent ad4d3f9 commit a0c3a3a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/views/messages/MessageEvent.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Relations } from 'matrix-js-sdk/src/models/relations';
2020
import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon';
2121
import { M_LOCATION } from 'matrix-js-sdk/src/@types/location';
2222
import { M_POLL_START } from "matrix-events-sdk";
23+
import { MatrixEventEvent } from "matrix-js-sdk/src/models/event";
2324

2425
import SettingsStore from "../../../settings/SettingsStore";
2526
import { Mjolnir } from "../../../mjolnir/Mjolnir";
@@ -73,7 +74,12 @@ export default class MessageEvent extends React.Component<IProps> implements IMe
7374
}
7475
}
7576

77+
public componentDidMount(): void {
78+
this.props.mxEvent.addListener(MatrixEventEvent.Decrypted, this.onDecrypted);
79+
}
80+
7681
public componentWillUnmount() {
82+
this.props.mxEvent.removeListener(MatrixEventEvent.Decrypted, this.onDecrypted);
7783
this.mediaHelper?.destroy();
7884
}
7985

@@ -118,6 +124,14 @@ export default class MessageEvent extends React.Component<IProps> implements IMe
118124
return this.mediaHelper;
119125
}
120126

127+
private onDecrypted = (): void => {
128+
// Recheck MediaEventHelper eligibility as it can change when the event gets decrypted
129+
if (MediaEventHelper.isEligible(this.props.mxEvent)) {
130+
this.mediaHelper?.destroy();
131+
this.mediaHelper = new MediaEventHelper(this.props.mxEvent);
132+
}
133+
};
134+
121135
private onTileUpdate = () => {
122136
this.forceUpdate();
123137
};

0 commit comments

Comments
 (0)