Skip to content

Commit

Permalink
Save window bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Mar 12, 2017
1 parent 392cf9b commit 5758efd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "Jhen <developer@jhen.me>",
"license": "MIT",
"dependencies": {
"electron-config": "^0.2.1",
"react-devtools-core": "^2.0.4",
"source-map-support": "^0.4.1"
}
Expand Down
14 changes: 11 additions & 3 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { resolve } from 'path';
import { app, BrowserWindow, Menu } from 'electron';
import Config from 'electron-config';
import autoUpdate from './update';
import installExtensions from './extensions';
import { startListeningHandleURL } from './url-handle';
import { createContextMenu, createMenuTemplate } from './menu';

const config = new Config();
const iconPath = resolve(__dirname, 'logo.png');
let mainWindow = null;

startListeningHandleURL(() => mainWindow);

app.on('window-all-closed', () => app.quit());
// app.on('window-all-closed', () => app.quit());
app.on('ready', async () => {
await installExtensions();

mainWindow = new BrowserWindow({ width: 1024, height: 750, show: false });
mainWindow = new BrowserWindow({
width: 1024,
height: 750,
...config.get('winBounds'),
show: false,
});
createContextMenu(mainWindow);

mainWindow.loadURL(`file://${resolve(__dirname)}/app.html`);
Expand All @@ -28,7 +35,8 @@ app.on('ready', async () => {
mainWindow.checkUpdate = autoUpdate;
autoUpdate(mainWindow, iconPath);
});
mainWindow.on('closed', () => {
mainWindow.on('close', () => {
config.set('winBounds', mainWindow.getBounds());
mainWindow = null;
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"worker-loader": "^0.7.0"
},
"dependencies": {
"electron-config": "^0.2.1",
"electron-context-menu": "^0.8.0",
"electron-gh-releases": "^2.0.4",
"jsan": "^3.1.2",
Expand Down
2 changes: 2 additions & 0 deletions webpack/base.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ export default {
// just avoid warning.
// this is not really used from ws. (it used fallback)
'utf-8-validate', 'bufferutil',
// https://github.com/sindresorhus/conf/blob/master/index.js#L13
'electron-config',
],
};
29 changes: 29 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,15 @@ concat-stream@^1.4.6, concat-stream@^1.4.7:
readable-stream "^2.2.2"
typedarray "^0.0.6"

conf@^0.11.1:
version "0.11.2"
resolved "https://registry.yarnpkg.com/conf/-/conf-0.11.2.tgz#879f479267600483e502583462ca4063fc9779b2"
dependencies:
dot-prop "^3.0.0"
env-paths "^0.3.0"
mkdirp "^0.5.1"
pkg-up "^1.0.0"

connect-history-api-fallback@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.3.0.tgz#e51d17f8f0ef0db90a64fdb47de3051556e9f169"
Expand Down Expand Up @@ -1714,6 +1723,12 @@ domain-browser@^1.1.1:
version "1.1.7"
resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc"

dot-prop@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177"
dependencies:
is-obj "^1.0.0"

dragula@3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/dragula/-/dragula-3.7.2.tgz#4a35c9d3981ffac1a949c29ca7285058e87393ce"
Expand Down Expand Up @@ -1748,6 +1763,12 @@ electron-chromedriver@~1.6.0:
electron-download "^3.1.0"
extract-zip "^1.6.0"

electron-config@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/electron-config/-/electron-config-0.2.1.tgz#7e12c26412d06bf3ed3896d0479df162986b95ba"
dependencies:
conf "^0.11.1"

electron-context-menu@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/electron-context-menu/-/electron-context-menu-0.8.0.tgz#60c4b5e29d5514007be8728a6ebdf3cb694c4e3e"
Expand Down Expand Up @@ -1886,6 +1907,10 @@ enhanced-resolve@~0.9.0:
memory-fs "^0.2.0"
tapable "^0.1.8"

env-paths@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-0.3.1.tgz#c30ccfcbc30c890943dc08a85582517ef00da463"

errno@^0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d"
Expand Down Expand Up @@ -3010,6 +3035,10 @@ is-number@^2.0.2, is-number@^2.1.0:
dependencies:
kind-of "^3.0.2"

is-obj@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"

is-path-cwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
Expand Down

0 comments on commit 5758efd

Please sign in to comment.