Skip to content

Commit 5638590

Browse files
abhigyankakashnimare
authored andcommitted
internal-links: Download file attachment links using downloadURL.
This commit download file attachments using downloadURL method of webContent, the same way loadURL opens internal links. This removes the use of hidden webview added in f70432f. Improves: #469.
1 parent 29ed009 commit 5638590

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

app/renderer/css/main.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,6 @@ webview {
284284
flex-direction: column;
285285
}
286286

287-
webview.download-webview {
288-
z-index: -1;
289-
pointer-events: none;
290-
}
291-
292287
webview.onload {
293288
transition: opacity 1s cubic-bezier(0.95, 0.05, 0.795, 0.035);
294289
}

app/renderer/js/components/handle-external-link.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const { shell } = require('electron').remote;
22
const LinkUtil = require('../utils/link-util');
33
const DomainUtil = require('../utils/domain-util');
4-
const hiddenWebView = require('../components/hidden-webview');
54

65
function handleExternalLink(event) {
76
const { url } = event;
@@ -16,12 +15,12 @@ function handleExternalLink(event) {
1615
if (isWhiteListURL) {
1716
event.preventDefault();
1817

19-
// only open the pdf, mp3, mp4 etc.. in hidden webview since opening the
20-
// image in webview will do nothing and will not save it
21-
// whereas the pdf will be saved to user desktop once openened in
22-
// in the hidden webview and will not trigger webview reload
18+
// download txt, pdf, mp3, mp4 etc.. by using downloadURL in the
19+
// main process which allows the user to save the files to their desktop
20+
// and not trigger webview reload while image in webview will
21+
// do nothing and will not save it
2322
if (!LinkUtil.isImage(url) && isUploadsURL) {
24-
hiddenWebView.loadURL(url);
23+
this.$el.downloadURL(url);
2524
return;
2625
}
2726

app/renderer/js/components/hidden-webview.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)