[MM-22229] migrate some operations to promises (#1223)
* [MM-22229] convert download dialog into promises * use callback * [MM-22231] switch clearcache to promises * [MM-22232] migrate flush cookies to promises
This commit is contained in:
@@ -4,10 +4,8 @@
|
||||
import {app} from 'electron';
|
||||
|
||||
function flushCookiesStore(session) {
|
||||
session.cookies.flushStore((err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
session.cookies.flushStore().catch((err) => {
|
||||
console.log(`There was a problem flushing cookies:\n${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -17,10 +17,17 @@ export default function downloadURL(browserWindow, URL, callback) {
|
||||
const dialogOptions = {
|
||||
defaultPath: path.join(app.getPath('downloads'), file),
|
||||
};
|
||||
dialog.showSaveDialog(browserWindow, dialogOptions, (filename) => {
|
||||
if (filename) {
|
||||
saveResponseBody(response, filename, callback);
|
||||
dialog.showSaveDialog(
|
||||
browserWindow,
|
||||
dialogOptions
|
||||
).then(
|
||||
(filename) => {
|
||||
if (filename) {
|
||||
saveResponseBody(response, filename, callback);
|
||||
}
|
||||
}
|
||||
).catch((err) => {
|
||||
callback(err);
|
||||
});
|
||||
}).on('error', callback);
|
||||
request.end();
|
||||
|
@@ -144,9 +144,7 @@ function createTemplate(mainWindow, config, isDev) {
|
||||
if (focusedWindow === mainWindow) {
|
||||
mainWindow.webContents.send('clear-cache-and-reload-tab');
|
||||
} else {
|
||||
focusedWindow.webContents.session.clearCache(() => {
|
||||
focusedWindow.reload();
|
||||
});
|
||||
focusedWindow.webContents.session.clearCache().then(focusedWindow.reload);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user