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

Commit 6e390fe

Browse files
committed
Fix refreshing the page not showing a download
1 parent 6176f03 commit 6e390fe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/views/messages/MessageActionBar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { canCancel } from "../context_menus/MessageContextMenu";
3333
import Resend from "../../../Resend";
3434
import { MatrixClientPeg } from "../../../MatrixClientPeg";
3535
import { canTileDownload } from "./IMediaBody";
36+
import {MediaEventHelper} from "../../../utils/MediaEventHelper";
3637

3738
const OptionsButton = ({ mxEvent, getTile, getReplyThread, permalinkCreator, onFocusChange }) => {
3839
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
@@ -177,6 +178,11 @@ export default class MessageActionBar extends React.PureComponent {
177178
};
178179

179180
onDownloadClick = async (ev) => {
181+
if (!this.props.getTile || !this.props.getTile().getMediaHelper) {
182+
console.warn("Action bar triggered a download but the event tile is missing a media helper");
183+
return;
184+
}
185+
180186
// TODO: Maybe just call into MFileBody and render it as null
181187
const src = this.props.getTile().getMediaHelper();
182188
const a = document.createElement("a");
@@ -279,8 +285,8 @@ export default class MessageActionBar extends React.PureComponent {
279285
/>);
280286
}
281287

282-
const tile = this.props.getTile && this.props.getTile();
283-
if (canTileDownload(tile)) {
288+
// XXX: Assuming that the underlying tile will be a media event if it is eligible media.
289+
if (MediaEventHelper.isEligible(this.props.mxEvent)) {
284290
toolbarOpts.splice(0, 0, <RovingAccessibleTooltipButton
285291
className="mx_MessageActionBar_maskButton mx_MessageActionBar_downloadButton"
286292
title={_t("Download")}

0 commit comments

Comments
 (0)