Add an option to hide image previews

Applies to images, stickers, and URL previews.

Fixes https://github.com/vector-im/riot-web/issues/10735
This commit is contained in:
Travis Ralston 2019-09-27 21:08:31 -06:00
parent 55e834f0ae
commit 59b29e4a7f
8 changed files with 102 additions and 16 deletions

View file

@ -19,10 +19,15 @@ limitations under the License.
import React from 'react';
import MImageBody from './MImageBody';
import sdk from '../../../index';
import {_t} from "../../../languageHandler";
export default class MStickerBody extends MImageBody {
// Empty to prevent default behaviour of MImageBody
onClick() {
// Mostly empty to prevent default behaviour of MImageBody
onClick(ev) {
ev.preventDefault();
if (!this.state.showImage) {
this.showImage();
}
}
// MStickerBody doesn't need a wrapping `<a href=...>`, but it does need extra padding
@ -34,6 +39,14 @@ export default class MStickerBody extends MImageBody {
// Placeholder to show in place of the sticker image if
// img onLoad hasn't fired yet.
getPlaceholder() {
if (!this.state.showImage) {
return (
<a className="mx_MStickerBody_hidden" onClick={this.onClick} href="#">
<span>{_t("Click to show sticker")}</span>
</a>
);
}
const TintableSVG = sdk.getComponent('elements.TintableSvg');
return <TintableSVG src={require("../../../../res/img/icons-show-stickers.svg")} width="75" height="75" />;
}