@@ -33,6 +33,7 @@ import { canCancel } from "../context_menus/MessageContextMenu";
33
33
import Resend from "../../../Resend" ;
34
34
import { MatrixClientPeg } from "../../../MatrixClientPeg" ;
35
35
import { canTileDownload } from "./IMediaBody" ;
36
+ import { MediaEventHelper } from "../../../utils/MediaEventHelper" ;
36
37
37
38
const OptionsButton = ( { mxEvent, getTile, getReplyThread, permalinkCreator, onFocusChange } ) => {
38
39
const [ menuDisplayed , button , openMenu , closeMenu ] = useContextMenu ( ) ;
@@ -177,6 +178,11 @@ export default class MessageActionBar extends React.PureComponent {
177
178
} ;
178
179
179
180
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
+
180
186
// TODO: Maybe just call into MFileBody and render it as null
181
187
const src = this . props . getTile ( ) . getMediaHelper ( ) ;
182
188
const a = document . createElement ( "a" ) ;
@@ -279,8 +285,8 @@ export default class MessageActionBar extends React.PureComponent {
279
285
/> ) ;
280
286
}
281
287
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 ) ) {
284
290
toolbarOpts . splice ( 0 , 0 , < RovingAccessibleTooltipButton
285
291
className = "mx_MessageActionBar_maskButton mx_MessageActionBar_downloadButton"
286
292
title = { _t ( "Download" ) }
0 commit comments