Unverified Commit acad507e authored by Tasso Evangelista's avatar Tasso Evangelista Committed by GitHub

Merge pull request #869 from RocketChat/fix/window-state-av-eperm

[FIX] Window state errors on save when antivirus software is present
parents 2323f431 329dc69f
......@@ -6,7 +6,6 @@
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
import url from 'url';
import path from 'path';
import { debounce } from 'lodash';
import windowStateKeeper from './windowState';
import env from '../env';
......@@ -29,13 +28,13 @@ const attachWindowStateHandling = (mainWindow) => {
// macOS only
app.on('activate', () => {
mainWindowState.saveState(mainWindow);
mainWindow.show();
});
app.on('before-quit', () => {
mainWindowState.saveState(mainWindow);
mainWindow.forceClose = true;
mainWindowState.saveState.flush();
mainWindow = null;
});
mainWindow.on('show', () => {
......@@ -43,10 +42,10 @@ const attachWindowStateHandling = (mainWindow) => {
});
mainWindow.on('close', function (event) {
if (mainWindow.forceClose) {
mainWindowState.saveState(mainWindow);
if (!mainWindow) {
return;
}
event.preventDefault();
if (mainWindow.isFullScreen()) {
mainWindow.once('leave-full-screen', () => {
......@@ -59,13 +58,13 @@ const attachWindowStateHandling = (mainWindow) => {
mainWindowState.saveState(mainWindow);
});
mainWindow.on('resize', debounce(() => {
mainWindow.on('resize', () => {
mainWindowState.saveState(mainWindow);
}), 1000);
});
mainWindow.on('move', debounce(() => {
mainWindow.on('move', () => {
mainWindowState.saveState(mainWindow);
}), 1000);
});
};
const attachIpcMessageHandling = (mainWindow) => {
......
......@@ -4,6 +4,7 @@
import { app } from 'electron';
import jetpack from 'fs-jetpack';
import { debounce } from 'lodash';
export default function (name, defaults) {
......@@ -61,7 +62,7 @@ export default function (name, defaults) {
get isMaximized () { return state.isMaximized; },
get isMinimized () { return state.isMinimized; },
get isHidden () { return state.isHidden; },
saveState,
saveState: debounce(saveState, 1000), // see https://github.com/RocketChat/Rocket.Chat.Electron/issues/181
loadState
};
}
......@@ -1380,7 +1380,7 @@ debug@3.1.0, debug@^3.0.0, debug@^3.1.0:
dependencies:
ms "2.0.0"
debuglog@^1.0.1:
debuglog@*, debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
......@@ -2838,7 +2838,7 @@ import-lazy@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"
imurmurhash@^0.1.4:
imurmurhash@*, imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
......@@ -3540,6 +3540,10 @@ lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
lodash._basetostring@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5"
......@@ -3555,11 +3559,25 @@ lodash._basevalues@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7"
lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
lodash._getnative@^3.0.0:
lodash._getnative@*, lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
......@@ -3641,7 +3659,7 @@ lodash.pick@^4.2.1:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
lodash.restparam@^3.0.0:
lodash.restparam@*, lodash.restparam@^3.0.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
......@@ -5107,7 +5125,7 @@ readable-stream@~2.1.0:
string_decoder "~0.10.x"
util-deprecate "~1.0.1"
readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
dependencies:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment