Revert "replace all require(.svg) with esm import" (#7969)

* Revert "replace all require(svgs) with esm import (#7948)"

This reverts commit 61cd463a3b.

* add .default to svg icon inline requires

Signed-off-by: Kerry Archibald <kerrya@element.io>

* add shameful eslint ignore

Signed-off-by: Kerry Archibald <kerrya@element.io>

* format eslintrc

Signed-off-by: Kerry Archibald <kerrya@element.io>

* add missed MFileBody change

Signed-off-by: Kerry Archibald <kerrya@element.io>

* one more broken svg

Signed-off-by: Kerry Archibald <kerrya@element.io>

* and ignore it

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-03-03 18:51:38 +01:00 committed by GitHub
parent 8a7ffb4f90
commit d98a73b003
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 119 additions and 131 deletions

View file

@ -29,7 +29,6 @@ import { PlaybackManager } from "../../../audio/PlaybackManager";
import { isVoiceMessage } from "../../../utils/EventUtils";
import { PlaybackQueue } from "../../../audio/PlaybackQueue";
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
import WarningSvg from '../../../../res/img/warning.svg';
interface IState {
error?: Error;
@ -97,7 +96,7 @@ export default class MAudioBody extends React.PureComponent<IBodyProps, IState>
if (this.state.error) {
return (
<span className="mx_MAudioBody">
<img src={WarningSvg} width="16" height="16" />
<img src={require("../../../../res/img/warning.svg").default} width="16" height="16" />
{ _t("Error processing audio message") }
</span>
);

View file

@ -30,14 +30,13 @@ import { IBodyProps } from "./IBodyProps";
import { FileDownloader } from "../../../utils/FileDownloader";
import TextWithTooltip from "../elements/TextWithTooltip";
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
import DownloadSvg from '../../../../res/img/download.svg';
export let DOWNLOAD_ICON_URL; // cached copy of the download.svg asset for the sandboxed iframe later on
async function cacheDownloadIcon() {
if (DOWNLOAD_ICON_URL) return; // cached already
// eslint-disable-next-line @typescript-eslint/no-var-requires
const svg = await fetch(DownloadSvg).then(r => r.text());
const svg = await fetch(require('../../../../res/img/download.svg').default).then(r => r.text());
DOWNLOAD_ICON_URL = "data:image/svg+xml;base64," + window.btoa(svg);
}

View file

@ -37,7 +37,6 @@ import { IBodyProps } from "./IBodyProps";
import { ImageSize, suggestedSize as suggestedImageSize } from "../../../settings/enums/ImageSize";
import { MatrixClientPeg } from '../../../MatrixClientPeg';
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
import WarningSvg from '../../../../res/img/warning.svg';
interface IState {
decryptedUrl?: string;
@ -544,7 +543,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
if (this.state.error !== null) {
return (
<div className="mx_MImageBody">
<img src={WarningSvg} width="16" height="16" />
<img src={require("../../../../res/img/warning.svg").default} width="16" height="16" />
{ _t("Error decrypting image") }
</div>
);

View file

@ -20,7 +20,6 @@ import MImageBody from './MImageBody';
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { BLURHASH_FIELD } from "../../../ContentMessages";
import Tooltip from "../elements/Tooltip";
import ShowStickersSvg from '../../../../res/img/icons-show-stickers.svg';
@replaceableComponent("views.messages.MStickerBody")
export default class MStickerBody extends MImageBody {
@ -46,7 +45,7 @@ export default class MStickerBody extends MImageBody {
// img onLoad hasn't fired yet.
protected getPlaceholder(width: number, height: number): JSX.Element {
if (this.props.mxEvent.getContent().info?.[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
return <img src={ShowStickersSvg} width="75" height="75" />;
return <img src={require("../../../../res/img/icons-show-stickers.svg").default} width="75" height="75" />;
}
// Tooltip to show on mouse over

View file

@ -29,7 +29,6 @@ import { IBodyProps } from "./IBodyProps";
import MFileBody from "./MFileBody";
import { ImageSize, suggestedSize as suggestedVideoSize } from "../../../settings/enums/ImageSize";
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
import WarningSvg from '../../../../res/img/warning.svg';
interface IState {
decryptedUrl?: string;
@ -258,7 +257,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
if (this.state.error !== null) {
return (
<span className="mx_MVideoBody">
<img src={WarningSvg} width="16" height="16" />
<img src={require("../../../../res/img/warning.svg").default} width="16" height="16" />
{ _t("Error decrypting video") }
</span>
);

View file

@ -22,7 +22,6 @@ import { _t } from "../../../languageHandler";
import RecordingPlayback from "../audio_messages/RecordingPlayback";
import MAudioBody from "./MAudioBody";
import MFileBody from "./MFileBody";
import WarningSvg from '../../../../res/img/warning.svg';
@replaceableComponent("views.messages.MVoiceMessageBody")
export default class MVoiceMessageBody extends MAudioBody {
@ -31,7 +30,7 @@ export default class MVoiceMessageBody extends MAudioBody {
if (this.state.error) {
return (
<span className="mx_MVoiceMessageBody">
<img src={WarningSvg} width="16" height="16" />
<img src={require("../../../../res/img/warning.svg").default} width="16" height="16" />
{ _t("Error processing voice message") }
</span>
);