[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:
parent
9b5f53a294
commit
f1baa03a8f
|
@ -227,9 +227,7 @@ export default class MattermostView extends React.Component {
|
|||
errorInfo: null,
|
||||
});
|
||||
const webContents = this.webviewRef.current.getWebContents();
|
||||
webContents.session.clearCache(() => {
|
||||
webContents.reload();
|
||||
});
|
||||
webContents.session.clearCache().then(webContents.reload);
|
||||
}
|
||||
|
||||
focusOnWebView = () => {
|
||||
|
|
|
@ -1123,10 +1123,7 @@ function wasUpdated(lastAppVersion) {
|
|||
function clearAppCache() {
|
||||
if (mainWindow) {
|
||||
console.log('Clear cache after update');
|
||||
mainWindow.webContents.session.clearCache(() => {
|
||||
//Restart after cache clear
|
||||
mainWindow.reload();
|
||||
});
|
||||
mainWindow.webContents.session.clearCache().then(mainWindow.reload);
|
||||
} else {
|
||||
//Wait for mainWindow
|
||||
setTimeout(clearAppCache, 100);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue