@@ -15,18 +15,15 @@ limitations under the License.
15
15
*/
16
16
17
17
import React , { createRef } from 'react' ;
18
- import PropTypes from 'prop-types' ;
19
18
import filesize from 'filesize' ;
20
19
import { _t } from '../../../languageHandler' ;
21
- import { decryptFile } from '../../../utils/DecryptFile' ;
22
20
import Modal from '../../../Modal' ;
23
21
import AccessibleButton from "../elements/AccessibleButton" ;
24
22
import { replaceableComponent } from "../../../utils/replaceableComponent" ;
25
23
import { mediaFromContent } from "../../../customisations/Media" ;
26
24
import ErrorDialog from "../dialogs/ErrorDialog" ;
27
25
import { TileShape } from "../rooms/EventTile" ;
28
- import { IContent , MatrixEvent } from "matrix-js-sdk/src" ;
29
- import { MediaEventHelper } from "../../../utils/MediaEventHelper" ;
26
+ import { IContent } from "matrix-js-sdk/src" ;
30
27
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent" ;
31
28
import { IBodyProps } from "./IBodyProps" ;
32
29
@@ -181,6 +178,8 @@ export default class MFileBody extends React.Component<IProps, IState> {
181
178
) ;
182
179
}
183
180
181
+ const showDownloadLink = this . props . tileShape || ! this . props . showGenericPlaceholder ;
182
+
184
183
if ( isEncrypted ) {
185
184
if ( ! this . state . decryptedBlob ) {
186
185
// Need to decrypt the attachment
@@ -205,12 +204,12 @@ export default class MFileBody extends React.Component<IProps, IState> {
205
204
// but it is not guaranteed between various browsers' settings.
206
205
return (
207
206
< span className = "mx_MFileBody" >
208
- { placeholder }
209
- < div className = "mx_MFileBody_download" >
207
+ { placeholder }
208
+ { showDownloadLink && < div className = "mx_MFileBody_download" >
210
209
< AccessibleButton onClick = { decrypt } >
211
210
{ _t ( "Decrypt %(text)s" , { text : text } ) }
212
211
</ AccessibleButton >
213
- </ div >
212
+ </ div > }
214
213
</ span >
215
214
) ;
216
215
}
@@ -237,8 +236,8 @@ export default class MFileBody extends React.Component<IProps, IState> {
237
236
// If the attachment is encrypted then put the link inside an iframe.
238
237
return (
239
238
< span className = "mx_MFileBody" >
240
- { placeholder }
241
- < div className = "mx_MFileBody_download" >
239
+ { placeholder }
240
+ { showDownloadLink && < div className = "mx_MFileBody_download" >
242
241
< div style = { { display : "none" } } >
243
242
{ /*
244
243
* Add dummy copy of the "a" tag
@@ -252,7 +251,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
252
251
onLoad = { onIframeLoad }
253
252
ref = { this . iframe }
254
253
sandbox = "allow-scripts allow-downloads allow-downloads-without-user-activation" />
255
- </ div >
254
+ </ div > }
256
255
</ span >
257
256
) ;
258
257
} else if ( contentUrl ) {
@@ -300,40 +299,24 @@ export default class MFileBody extends React.Component<IProps, IState> {
300
299
downloadProps [ "download" ] = fileName ;
301
300
}
302
301
303
- // If the attachment is not encrypted then we check whether we
304
- // are being displayed in the room timeline or in a list of
305
- // files in the right hand side of the screen.
306
- if ( this . props . tileShape === TileShape . FileGrid ) {
307
- return (
308
- < span className = "mx_MFileBody" >
309
- { placeholder }
310
- < div className = "mx_MFileBody_download" >
311
- < a className = "mx_MFileBody_downloadLink" { ...downloadProps } >
312
- { fileName }
313
- </ a >
314
- < div className = "mx_MImageBody_size" >
315
- { content . info && content . info . size ? filesize ( content . info . size ) : "" }
316
- </ div >
317
- </ div >
318
- </ span >
319
- ) ;
320
- } else {
321
- return (
322
- < span className = "mx_MFileBody" >
323
- { placeholder }
324
- < div className = "mx_MFileBody_download" >
325
- < a { ...downloadProps } >
326
- < span className = "mx_MFileBody_download_icon" />
327
- { _t ( "Download %(text)s" , { text : text } ) }
328
- </ a >
329
- </ div >
330
- </ span >
331
- ) ;
332
- }
302
+ return (
303
+ < span className = "mx_MFileBody" >
304
+ { placeholder }
305
+ { showDownloadLink && < div className = "mx_MFileBody_download" >
306
+ < a { ...downloadProps } >
307
+ < span className = "mx_MFileBody_download_icon" />
308
+ { _t ( "Download %(text)s" , { text : text } ) }
309
+ </ a >
310
+ { this . props . tileShape === TileShape . FileGrid && < div className = "mx_MImageBody_size" >
311
+ { content . info && content . info . size ? filesize ( content . info . size ) : "" }
312
+ </ div > }
313
+ </ div > }
314
+ </ span >
315
+ ) ;
333
316
} else {
334
317
const extra = text ? ( ': ' + text ) : '' ;
335
318
return < span className = "mx_MFileBody" >
336
- { placeholder }
319
+ { placeholder }
337
320
{ _t ( "Invalid file%(extra)s" , { extra : extra } ) }
338
321
</ span > ;
339
322
}
0 commit comments