Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 21d65d2

Browse files
committed
Fix the download icon on attachments
1 parent 57d82eb commit 21d65d2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/views/messages/MFileBody.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg';
2222
import sdk from '../../../index';
2323
import {decryptFile} from '../../../utils/DecryptFile';
2424
import Tinter from '../../../Tinter';
25-
import 'isomorphic-fetch';
25+
import request from 'browser-request';
2626
import q from 'q';
2727
import Modal from '../../../Modal';
2828

@@ -41,10 +41,13 @@ function updateTintedDownloadImage() {
4141
// Download the svg as an XML document.
4242
// We could cache the XML response here, but since the tint rarely changes
4343
// it's probably not worth it.
44-
q(fetch("img/download.svg")).then(function(response) {
45-
return response.text();
46-
}).then(function(svgText) {
47-
const svg = new DOMParser().parseFromString(svgText, "image/svg+xml");
44+
// Also note that we can't use fetch here because fetch doesn't support
45+
// file URLs, which the download image will be if we're running from
46+
// the filesystem (like in an Electron wrapper).
47+
request({uri: "img/download.svg"}, (err, response, body) => {
48+
if (err) return;
49+
50+
const svg = new DOMParser().parseFromString(body, "image/svg+xml");
4851
// Apply the fixups to the XML.
4952
const fixups = Tinter.calcSvgFixups([{contentDocument: svg}]);
5053
Tinter.applySvgFixups(fixups);
@@ -55,7 +58,7 @@ function updateTintedDownloadImage() {
5558
Object.keys(mounts).forEach(function(id) {
5659
mounts[id].tint();
5760
});
58-
}).done();
61+
});
5962
}
6063

6164
Tinter.registerTintable(updateTintedDownloadImage);

0 commit comments

Comments
 (0)