mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-02-07 08:52:28 +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 url = require('url');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const MAILTO_PREFIX = "mailto:";
|
const MAILTO_PREFIX = "mailto:";
|
||||||
|
|
||||||
@ -205,6 +206,9 @@ function onEditableContextMenu(ev, params) {
|
|||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcMain.on('userDownloadOpen', function(ev, {path}) {
|
||||||
|
shell.openPath(path);
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = (webContents) => {
|
module.exports = (webContents) => {
|
||||||
webContents.on('new-window', onWindowOrNavigate);
|
webContents.on('new-window', onWindowOrNavigate);
|
||||||
@ -222,4 +226,16 @@ module.exports = (webContents) => {
|
|||||||
onEditableContextMenu(ev, params);
|
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