mirror of
https://github.com/vector-im/element-desktop.git
synced 2024-09-09 22:05:10 +00:00
Merge pull request #106 from vector-im/t3chguy/download_toast
Show expiring toast on completed downloads to prompt user to open
This commit is contained in:
commit
4ca58eebf9
1 changed files with 17 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
|||
const {clipboard, nativeImage, Menu, MenuItem, shell, dialog} = require('electron');
|
||||
const {clipboard, nativeImage, Menu, MenuItem, shell, dialog, ipcMain} = require('electron');
|
||||
const url = require('url');
|
||||
const fs = require('fs');
|
||||
const request = require('request');
|
||||
const path = require('path');
|
||||
|
||||
const MAILTO_PREFIX = "mailto:";
|
||||
|
||||
|
@ -205,6 +206,9 @@ function onEditableContextMenu(ev, params) {
|
|||
ev.preventDefault();
|
||||
}
|
||||
|
||||
ipcMain.on('userDownloadOpen', function(ev, {path}) {
|
||||
shell.openPath(path);
|
||||
});
|
||||
|
||||
module.exports = (webContents) => {
|
||||
webContents.on('new-window', onWindowOrNavigate);
|
||||
|
@ -222,4 +226,16 @@ module.exports = (webContents) => {
|
|||
onEditableContextMenu(ev, params);
|
||||
}
|
||||
});
|
||||
|
||||
webContents.session.on('will-download', (event, item) => {
|
||||
item.once('done', (event, state) => {
|
||||
if (state === 'completed') {
|
||||
const savePath = item.getSavePath();
|
||||
webContents.send('userDownloadCompleted', {
|
||||
path: savePath,
|
||||
name: path.basename(savePath),
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue