Only show download link below media if it's not in the timeline
This commit is contained in:
parent
7ba0adba77
commit
623f2e7613
5 changed files with 33 additions and 45 deletions
|
@ -97,7 +97,7 @@ export default class MAudioBody extends React.PureComponent<IBodyProps, IState>
|
||||||
return (
|
return (
|
||||||
<span className="mx_MAudioBody">
|
<span className="mx_MAudioBody">
|
||||||
<AudioPlayer playback={this.state.playback} mediaName={this.props.mxEvent.getContent().body} />
|
<AudioPlayer playback={this.state.playback} mediaName={this.props.mxEvent.getContent().body} />
|
||||||
{/*<MFileBody {...this.props} decryptedBlob={this.state.decryptedBlob} showGenericPlaceholder={false} />*/}
|
{ this.props.tileShape && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,15 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { createRef } from 'react';
|
import React, { createRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import filesize from 'filesize';
|
import filesize from 'filesize';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import { decryptFile } from '../../../utils/DecryptFile';
|
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { mediaFromContent } from "../../../customisations/Media";
|
import { mediaFromContent } from "../../../customisations/Media";
|
||||||
import ErrorDialog from "../dialogs/ErrorDialog";
|
import ErrorDialog from "../dialogs/ErrorDialog";
|
||||||
import { TileShape } from "../rooms/EventTile";
|
import { TileShape } from "../rooms/EventTile";
|
||||||
import { IContent, MatrixEvent } from "matrix-js-sdk/src";
|
import { IContent } from "matrix-js-sdk/src";
|
||||||
import { MediaEventHelper } from "../../../utils/MediaEventHelper";
|
|
||||||
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
|
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
|
||||||
import { IBodyProps } from "./IBodyProps";
|
import { IBodyProps } from "./IBodyProps";
|
||||||
|
|
||||||
|
@ -181,6 +178,8 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showDownloadLink = this.props.tileShape || !this.props.showGenericPlaceholder;
|
||||||
|
|
||||||
if (isEncrypted) {
|
if (isEncrypted) {
|
||||||
if (!this.state.decryptedBlob) {
|
if (!this.state.decryptedBlob) {
|
||||||
// Need to decrypt the attachment
|
// Need to decrypt the attachment
|
||||||
|
@ -205,12 +204,12 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
// but it is not guaranteed between various browsers' settings.
|
// but it is not guaranteed between various browsers' settings.
|
||||||
return (
|
return (
|
||||||
<span className="mx_MFileBody">
|
<span className="mx_MFileBody">
|
||||||
{placeholder}
|
{ placeholder }
|
||||||
<div className="mx_MFileBody_download">
|
{ showDownloadLink && <div className="mx_MFileBody_download">
|
||||||
<AccessibleButton onClick={decrypt}>
|
<AccessibleButton onClick={decrypt}>
|
||||||
{ _t("Decrypt %(text)s", { text: text }) }
|
{ _t("Decrypt %(text)s", { text: text }) }
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>
|
</div> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -237,8 +236,8 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
// If the attachment is encrypted then put the link inside an iframe.
|
// If the attachment is encrypted then put the link inside an iframe.
|
||||||
return (
|
return (
|
||||||
<span className="mx_MFileBody">
|
<span className="mx_MFileBody">
|
||||||
{placeholder}
|
{ placeholder }
|
||||||
<div className="mx_MFileBody_download">
|
{ showDownloadLink && <div className="mx_MFileBody_download">
|
||||||
<div style={{ display: "none" }}>
|
<div style={{ display: "none" }}>
|
||||||
{ /*
|
{ /*
|
||||||
* Add dummy copy of the "a" tag
|
* Add dummy copy of the "a" tag
|
||||||
|
@ -252,7 +251,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
onLoad={onIframeLoad}
|
onLoad={onIframeLoad}
|
||||||
ref={this.iframe}
|
ref={this.iframe}
|
||||||
sandbox="allow-scripts allow-downloads allow-downloads-without-user-activation" />
|
sandbox="allow-scripts allow-downloads allow-downloads-without-user-activation" />
|
||||||
</div>
|
</div> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else if (contentUrl) {
|
} else if (contentUrl) {
|
||||||
|
@ -300,40 +299,24 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
downloadProps["download"] = fileName;
|
downloadProps["download"] = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the attachment is not encrypted then we check whether we
|
|
||||||
// are being displayed in the room timeline or in a list of
|
|
||||||
// files in the right hand side of the screen.
|
|
||||||
if (this.props.tileShape === TileShape.FileGrid) {
|
|
||||||
return (
|
return (
|
||||||
<span className="mx_MFileBody">
|
<span className="mx_MFileBody">
|
||||||
{placeholder}
|
{ placeholder }
|
||||||
<div className="mx_MFileBody_download">
|
{ showDownloadLink && <div className="mx_MFileBody_download">
|
||||||
<a className="mx_MFileBody_downloadLink" {...downloadProps}>
|
|
||||||
{ fileName }
|
|
||||||
</a>
|
|
||||||
<div className="mx_MImageBody_size">
|
|
||||||
{ content.info && content.info.size ? filesize(content.info.size) : "" }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<span className="mx_MFileBody">
|
|
||||||
{placeholder}
|
|
||||||
<div className="mx_MFileBody_download">
|
|
||||||
<a {...downloadProps}>
|
<a {...downloadProps}>
|
||||||
<span className="mx_MFileBody_download_icon" />
|
<span className="mx_MFileBody_download_icon" />
|
||||||
{ _t("Download %(text)s", { text: text }) }
|
{ _t("Download %(text)s", { text: text }) }
|
||||||
</a>
|
</a>
|
||||||
</div>
|
{ this.props.tileShape === TileShape.FileGrid && <div className="mx_MImageBody_size">
|
||||||
|
{ content.info && content.info.size ? filesize(content.info.size) : "" }
|
||||||
|
</div>}
|
||||||
|
</div> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const extra = text ? (': ' + text) : '';
|
const extra = text ? (': ' + text) : '';
|
||||||
return <span className="mx_MFileBody">
|
return <span className="mx_MFileBody">
|
||||||
{placeholder}
|
{ placeholder }
|
||||||
{ _t("Invalid file%(extra)s", { extra: extra }) }
|
{ _t("Invalid file%(extra)s", { extra: extra }) }
|
||||||
</span>;
|
</span>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,10 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
|
|
||||||
// Overidden by MStickerBody
|
// Overidden by MStickerBody
|
||||||
protected getFileBody(): JSX.Element {
|
protected getFileBody(): JSX.Element {
|
||||||
return <MFileBody {...this.props} decryptedBlob={this.state.decryptedBlob} showGenericPlaceholder={false} />;
|
// We only ever need the download bar if we're appearing outside of the timeline
|
||||||
|
if (this.props.tileShape) {
|
||||||
|
return <MFileBody {...this.props} showGenericPlaceholder={false} />;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { mediaFromContent } from "../../../customisations/Media";
|
||||||
import { BLURHASH_FIELD } from "../../../ContentMessages";
|
import { BLURHASH_FIELD } from "../../../ContentMessages";
|
||||||
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
|
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
|
||||||
import { IBodyProps } from "./IBodyProps";
|
import { IBodyProps } from "./IBodyProps";
|
||||||
|
import MFileBody from "./MFileBody";
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
decryptedUrl?: string;
|
decryptedUrl?: string;
|
||||||
|
@ -268,7 +269,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
|
||||||
onPlay={this.videoOnPlay}
|
onPlay={this.videoOnPlay}
|
||||||
>
|
>
|
||||||
</video>
|
</video>
|
||||||
{/*<MFileBody {...this.props} decryptedBlob={this.state.decryptedBlob} showGenericPlaceholder={false} />*/}
|
{ this.props.tileShape && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import InlineSpinner from '../elements/InlineSpinner';
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import RecordingPlayback from "../audio_messages/RecordingPlayback";
|
import RecordingPlayback from "../audio_messages/RecordingPlayback";
|
||||||
import MAudioBody from "./MAudioBody";
|
import MAudioBody from "./MAudioBody";
|
||||||
|
import MFileBody from "./MFileBody";
|
||||||
|
|
||||||
@replaceableComponent("views.messages.MVoiceMessageBody")
|
@replaceableComponent("views.messages.MVoiceMessageBody")
|
||||||
export default class MVoiceMessageBody extends MAudioBody {
|
export default class MVoiceMessageBody extends MAudioBody {
|
||||||
|
@ -50,7 +51,7 @@ export default class MVoiceMessageBody extends MAudioBody {
|
||||||
return (
|
return (
|
||||||
<span className="mx_MVoiceMessageBody">
|
<span className="mx_MVoiceMessageBody">
|
||||||
<RecordingPlayback playback={this.state.playback} tileShape={this.props.tileShape} />
|
<RecordingPlayback playback={this.state.playback} tileShape={this.props.tileShape} />
|
||||||
{/*<MFileBody {...this.props} decryptedBlob={this.state.decryptedBlob} showGenericPlaceholder={false} />*/}
|
{ this.props.tileShape && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue