[MM-52380] Fix unhandled rejection when clearing app cache (#2696)
* [MM-52380] Fix unhandled rejection when clearing app cache * Make sure the window is loaded first --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
@@ -345,11 +345,6 @@ async function initializeAfterAppReady() {
|
|||||||
updateSpellCheckerLocales();
|
updateSpellCheckerLocales();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasUpdated(AppVersionManager.lastAppVersion)) {
|
|
||||||
clearAppCache();
|
|
||||||
}
|
|
||||||
AppVersionManager.lastAppVersion = app.getVersion();
|
|
||||||
|
|
||||||
if (typeof Config.canUpgrade === 'undefined') {
|
if (typeof Config.canUpgrade === 'undefined') {
|
||||||
// windows might not be ready, so we have to wait until it is
|
// windows might not be ready, so we have to wait until it is
|
||||||
Config.once('update', () => {
|
Config.once('update', () => {
|
||||||
@@ -472,6 +467,11 @@ async function initializeAfterAppReady() {
|
|||||||
callback(urlUtils.isTrustedURL(requestingURL, serverURL));
|
callback(urlUtils.isTrustedURL(requestingURL, serverURL));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (wasUpdated(AppVersionManager.lastAppVersion)) {
|
||||||
|
clearAppCache();
|
||||||
|
}
|
||||||
|
AppVersionManager.lastAppVersion = app.getVersion();
|
||||||
|
|
||||||
handleMainWindowIsShown();
|
handleMainWindowIsShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,7 +91,11 @@ export function clearAppCache() {
|
|||||||
// TODO: clear cache on browserviews, not in the renderer.
|
// TODO: clear cache on browserviews, not in the renderer.
|
||||||
const mainWindow = MainWindow.get();
|
const mainWindow = MainWindow.get();
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.webContents.session.clearCache().then(mainWindow.reload);
|
mainWindow.webContents.session.clearCache().
|
||||||
|
then(mainWindow.webContents.reload).
|
||||||
|
catch((err) => {
|
||||||
|
log.error('clearAppCache', err);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
//Wait for mainWindow
|
//Wait for mainWindow
|
||||||
setTimeout(clearAppCache, 100);
|
setTimeout(clearAppCache, 100);
|
||||||
|
Reference in New Issue
Block a user