Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Fix attaching to menubar causes crashes after launching #270

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"repository": "https://github.com/quanglam2807/webcatalog",
"author": "Quang Lam <[email protected]>",
"dependencies": {
"electron": "5.0.4",
"electron": "5.0.6",
"electron-is-dev": "1.1.0",
"electron-settings": "3.2.0",
"electron-spellchecker": "2.1.0",
Expand All @@ -26,7 +26,7 @@
"node-fetch": "2.6.0",
"request": "2.88.0",
"request-promise-native": "1.0.7",
"semver": "6.1.1",
"semver": "6.2.0",
"uuid": "3.3.2"
},
"devDependencies": {
Expand All @@ -35,13 +35,13 @@
"babel-preset-env": "1.7.0",
"babel-preset-react": "6.24.1",
"classnames": "2.2.6",
"concurrently": "4.1.0",
"concurrently": "4.1.1",
"cross-env": "5.2.0",
"eslint": "5.16.0",
"eslint-config-airbnb": "17.1.0",
"eslint-plugin-import": "2.17.3",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-react": "7.13.0",
"eslint-config-airbnb": "17.1.1",
"eslint-plugin-import": "2.18.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.2",
"lodash.camelcase": "4.3.0",
"prop-types": "15.7.2",
"react": "16.8.6",
Expand Down
17 changes: 9 additions & 8 deletions template/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ if (!gotTheLock) {
app.commandLine.appendSwitch('widevine-cdm-version', WIDEVINE_VERSION);

const commonInit = () => {
mainWindow.create();
mainWindow.createAsync()
.then(() => {
createMenu();

createMenu();
const workspaceObjects = getWorkspaces();

const workspaceObjects = getWorkspaces();

Object.keys(workspaceObjects).forEach((id) => {
const workspace = workspaceObjects[id];
addView(mainWindow.get(), workspace);
});
Object.keys(workspaceObjects).forEach((id) => {
const workspace = workspaceObjects[id];
addView(mainWindow.get(), workspace);
});
});
};

app.on('ready', () => {
Expand Down
42 changes: 32 additions & 10 deletions template/public/windows/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ const get = () => {
return win;
};

const create = () => {
const createAsync = () => {
const attachToMenubar = getPreference('attachToMenubar');
if (attachToMenubar) {
mb = menubar({
index: REACT_PATH,
icon: path.resolve(__dirname, '..', 'menubar-icon.png'),
preloadWindow: true,
browserWindow: {
webPreferences: {
nodeIntegration: true,
},
},
});

const contextMenu = Menu.buildFromTemplate([
Expand All @@ -53,11 +58,19 @@ const create = () => {
},
]);

mb.tray.on('right-click', () => {
mb.tray.popUpContextMenu(contextMenu);
return new Promise((resolve, reject) => {
try {
mb.on('ready', () => {
mb.tray.on('right-click', () => {
mb.tray.popUpContextMenu(contextMenu);
});

resolve();
});
} catch (e) {
reject(e);
}
});

return;
}


Expand Down Expand Up @@ -112,14 +125,23 @@ const create = () => {
win.on('closed', () => {
win = null;
});

return Promise.resolve();
};

const show = () => {
const attachToMenubar = getPreference('attachToMenubar');
if (win == null) {
create();
} else if (attachToMenubar) {
mb.showWindow();

if (attachToMenubar) {
if (mb == null) {
createAsync();
} else {
mb.on('ready', () => {
mb.showWindow();
});
}
} else if (win == null) {
createAsync();
} else {
win.show();
}
Expand All @@ -132,7 +154,7 @@ const send = (...args) => {
};

module.exports = {
create,
createAsync,
get,
send,
show,
Expand Down
100 changes: 60 additions & 40 deletions template/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@
dependencies:
regenerator-runtime "^0.13.2"

"@babel/runtime@^7.3.1":
"@babel/runtime@^7.3.1", "@babel/runtime@^7.4.5":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
integrity sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==
Expand Down Expand Up @@ -3238,10 +3238,10 @@ [email protected], concat-stream@^1.5.0:
readable-stream "^2.2.2"
typedarray "^0.0.6"

[email protected].0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-4.1.0.tgz#17fdf067da71210685d9ea554423ef239da30d33"
integrity sha512-pwzXCE7qtOB346LyO9eFWpkFJVO3JQZ/qU/feGeaAHiX1M3Rw3zgXKc5cZ8vSH5DGygkjzLFDzA/pwoQDkRNGg==
[email protected].1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-4.1.1.tgz#42cf84d625163f3f5b2e2262568211ad76e1dbe8"
integrity sha512-48+FE5RJ0qc8azwKv4keVQWlni1hZeSjcWr8shBelOBtBHcKj1aJFM9lHRiSc1x7lq416pkvsqfBMhSRja+Lhw==
dependencies:
chalk "^2.4.1"
date-fns "^1.23.0"
Expand All @@ -3253,7 +3253,7 @@ [email protected]:
tree-kill "^1.1.0"
yargs "^12.0.1"

confusing-browser-globals@^1.0.7:
confusing-browser-globals@^1.0.5, confusing-browser-globals@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.7.tgz#5ae852bd541a910e7ffb2dbb864a2d21a36ad29b"
integrity sha512-cgHI1azax5ATrZ8rJ+ODDML9Fvu67PimB6aNxBrc/QwSaDaM9eTfIEUHx3bBLJJ82ioSb+/5zfsMCCEJax3ByQ==
Expand Down Expand Up @@ -4143,10 +4143,10 @@ [email protected]:
jsonfile "^4.0.0"
mkdirp "^0.5.1"

[email protected].4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/electron/-/electron-5.0.4.tgz#2e0d09055363e983f4a73317cde4821c39617b02"
integrity sha512-7QaKorvANvP+azMT7wElx33oLlqw8QxmLs7/outfH7LC5amErk4EUtWDesQ6Zgr+s5pYFbykl8ZtJ4ZGXER05g==
[email protected].6:
version "5.0.6"
resolved "https://registry.yarnpkg.com/electron/-/electron-5.0.6.tgz#e3ca4a58b5716fceef3fb64e1fd2222dd9c51de0"
integrity sha512-0L53lv26eDhaaNxL6DqXGQrQOEAYbrQg40stRSb2pzrY06kwPbABzXEiaCvEsBuKUQ+9OQBbVyyvXRbLJlun/A==
dependencies:
"@types/node" "^10.12.18"
electron-download "^4.1.0"
Expand Down Expand Up @@ -4270,23 +4270,23 @@ escodegen@^1.11.0, escodegen@^1.9.1:
optionalDependencies:
source-map "~0.6.1"

eslint-config-airbnb-base@^13.1.0:
version "13.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz#b5a1b480b80dfad16433d6c4ad84e6605052c05c"
integrity sha512-XWwQtf3U3zIoKO1BbHh6aUhJZQweOwSt4c2JrPDg9FP3Ltv3+YfEv7jIDB8275tVnO/qOHbfuYg3kzw6Je7uWw==
eslint-config-airbnb-base@^13.2.0:
version "13.2.0"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.2.0.tgz#f6ea81459ff4dec2dda200c35f1d8f7419d57943"
integrity sha512-1mg/7eoB4AUeB0X1c/ho4vb2gYkNH8Trr/EgCT/aGmKhhG+F6vF5s8+iRBlWAzFIAphxIdp3YfEKgEl0f9Xg+w==
dependencies:
eslint-restricted-globals "^0.1.1"
confusing-browser-globals "^1.0.5"
object.assign "^4.1.0"
object.entries "^1.0.4"
object.entries "^1.1.0"

[email protected].0:
version "17.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-17.1.0.tgz#3964ed4bc198240315ff52030bf8636f42bc4732"
integrity sha512-R9jw28hFfEQnpPau01NO5K/JWMGLi6aymiF6RsnMURjTk+MqZKllCqGK/0tOvHkPi/NWSSOU2Ced/GX++YxLnw==
[email protected].1:
version "17.1.1"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-17.1.1.tgz#2272e0b86bb1e2b138cdf88d07a3b6f4cda3d626"
integrity sha512-xCu//8a/aWqagKljt+1/qAM62BYZeNq04HmdevG5yUGWpja0I/xhqd6GdLRch5oetEGFiJAnvtGuTEAese53Qg==
dependencies:
eslint-config-airbnb-base "^13.1.0"
eslint-config-airbnb-base "^13.2.0"
object.assign "^4.1.0"
object.entries "^1.0.4"
object.entries "^1.1.0"

eslint-config-react-app@^4.0.1:
version "4.0.1"
Expand Down Expand Up @@ -4345,10 +4345,10 @@ [email protected]:
read-pkg-up "^2.0.0"
resolve "^1.9.0"

eslint-plugin-import@2.17.3:
version "2.17.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz#00548b4434c18faebaba04b24ae6198f280de189"
integrity sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==
eslint-plugin-import@2.18.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.18.0.tgz#7a5ba8d32622fb35eb9c8db195c2090bd18a3678"
integrity sha512-PZpAEC4gj/6DEMMoU2Df01C5c50r7zdGIN52Yfi7CvvWaYssG7Jt5R9nFG5gmqodxNOz9vQS87xk6Izdtpdrig==
dependencies:
array-includes "^3.0.3"
contains-path "^0.1.0"
Expand Down Expand Up @@ -4376,6 +4376,21 @@ [email protected]:
has "^1.0.3"
jsx-ast-utils "^2.0.1"

[email protected]:
version "6.2.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.2.3.tgz#b872a09d5de51af70a97db1eea7dc933043708aa"
integrity sha512-CawzfGt9w83tyuVekn0GDPU9ytYtxyxyFZ3aSWROmnRRFQFT2BiPJd7jvRdzNDi6oLWaS2asMeYSNMjWTV4eNg==
dependencies:
"@babel/runtime" "^7.4.5"
aria-query "^3.0.0"
array-includes "^3.0.3"
ast-types-flow "^0.0.7"
axobject-query "^2.0.2"
damerau-levenshtein "^1.0.4"
emoji-regex "^7.0.2"
has "^1.0.3"
jsx-ast-utils "^2.2.1"

eslint-plugin-react-hooks@^1.5.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.6.0.tgz#348efcda8fb426399ac7b8609607c7b4025a6f5f"
Expand All @@ -4394,24 +4409,21 @@ [email protected]:
prop-types "^15.6.2"
resolve "^1.9.0"

eslint-plugin-react@7.13.0:
version "7.13.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.13.0.tgz#bc13fd7101de67996ea51b33873cd9dc2b7e5758"
integrity sha512-uA5LrHylu8lW/eAH3bEQe9YdzpPaFd9yAJTwTi/i/BKTD7j6aQMKVAdGM/ML72zD6womuSK7EiGtMKuK06lWjQ==
eslint-plugin-react@7.14.2:
version "7.14.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.14.2.tgz#94c193cc77a899ac0ecbb2766fbef88685b7ecc1"
integrity sha512-jZdnKe3ip7FQOdjxks9XPN0pjUKZYq48OggNMd16Sk+8VXx6JOvXmlElxROCgp7tiUsTsze3jd78s/9AFJP2mA==
dependencies:
array-includes "^3.0.3"
doctrine "^2.1.0"
has "^1.0.3"
jsx-ast-utils "^2.1.0"
object.entries "^1.1.0"
object.fromentries "^2.0.0"
object.values "^1.1.0"
prop-types "^15.7.2"
resolve "^1.10.1"

eslint-restricted-globals@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7"
integrity sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=

[email protected]:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
Expand Down Expand Up @@ -6834,6 +6846,14 @@ jsx-ast-utils@^2.0.1, jsx-ast-utils@^2.1.0:
dependencies:
array-includes "^3.0.3"

jsx-ast-utils@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.2.1.tgz#4d4973ebf8b9d2837ee91a8208cc66f3a2776cfb"
integrity sha512-v3FxCcAf20DayI+uxnCuw795+oOIkVu6EnJ1+kSzhqqTZHNkTZ7B66ZgLp4oLJ/gbA64cI0B7WRoHZMSRdyVRQ==
dependencies:
array-includes "^3.0.3"
object.assign "^4.1.0"

keyboard-layout@^2.0.15:
version "2.0.16"
resolved "https://registry.yarnpkg.com/keyboard-layout/-/keyboard-layout-2.0.16.tgz#b8c1036222c3c12f00c1e0296a032529c43e530e"
Expand Down Expand Up @@ -7752,7 +7772,7 @@ object.assign@^4.1.0:
has-symbols "^1.0.0"
object-keys "^1.0.11"

object.entries@^1.0.4:
object.entries@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.0.tgz#2024fc6d6ba246aee38bdb0ffd5cfbcf371b7519"
integrity sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==
Expand Down Expand Up @@ -9899,10 +9919,10 @@ [email protected], semver@^6.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==

semver@6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b"
integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==
semver@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db"
integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==

[email protected]:
version "0.16.2"
Expand Down