mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-31 05:29:58 +01:00
Show expiring toast on completed downloads to prompt user to open
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
a11feaca32
commit
891e7ca234
@ -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…
x
Reference in New Issue
Block a user