diff options
author | 2018-12-22 15:03:46 +0100 | |
---|---|---|
committer | 2018-12-22 15:03:46 +0100 | |
commit | 5ad6eea6ea24bf6b4cdb8b314150c6fa5f9da896 (patch) | |
tree | 11907a50c6ed914c13b9264fa233ec9c03f32579 | |
parent | bump version to b22 (diff) | |
download | ferdium-app-5ad6eea6ea24bf6b4cdb8b314150c6fa5f9da896.tar.gz ferdium-app-5ad6eea6ea24bf6b4cdb8b314150c6fa5f9da896.tar.zst ferdium-app-5ad6eea6ea24bf6b4cdb8b314150c6fa5f9da896.zip |
Make electron 4 compatible
-rw-r--r-- | .babelrc | 2 | ||||
-rw-r--r-- | package-lock.json | 126 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/index.js | 80 | ||||
-rw-r--r-- | src/models/Service.js | 13 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 17 | ||||
-rw-r--r-- | src/webview/recipe.js | 17 |
7 files changed, 151 insertions, 106 deletions
@@ -4,7 +4,7 @@ | |||
4 | "@babel/preset-env", | 4 | "@babel/preset-env", |
5 | { | 5 | { |
6 | "targets": { | 6 | "targets": { |
7 | "electron": 2 | 7 | "electron": 4 |
8 | } | 8 | } |
9 | } | 9 | } |
10 | ], | 10 | ], |
diff --git a/package-lock.json b/package-lock.json index 16fe71944..0bd55d1c4 100644 --- a/package-lock.json +++ b/package-lock.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "name": "franz", | 2 | "name": "franz", |
3 | "version": "5.0.0-beta.21", | 3 | "version": "5.0.0-beta.22", |
4 | "lockfileVersion": 1, | 4 | "lockfileVersion": 1, |
5 | "requires": true, | 5 | "requires": true, |
6 | "dependencies": { | 6 | "dependencies": { |
@@ -1203,9 +1203,9 @@ | |||
1203 | } | 1203 | } |
1204 | }, | 1204 | }, |
1205 | "@types/node": { | 1205 | "@types/node": { |
1206 | "version": "8.10.38", | 1206 | "version": "8.10.39", |
1207 | "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", | 1207 | "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.39.tgz", |
1208 | "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", | 1208 | "integrity": "sha512-rE7fktr02J8ybFf6eysife+WF+L4sAHWzw09DgdCebEu+qDwMvv4zl6Bc+825ttGZP73kCKxa3dhJOoGJ8+5mA==", |
1209 | "dev": true | 1209 | "dev": true |
1210 | }, | 1210 | }, |
1211 | "abbrev": { | 1211 | "abbrev": { |
@@ -3548,13 +3548,13 @@ | |||
3548 | "dev": true | 3548 | "dev": true |
3549 | }, | 3549 | }, |
3550 | "electron": { | 3550 | "electron": { |
3551 | "version": "2.0.13", | 3551 | "version": "4.0.0-beta.9", |
3552 | "resolved": "https://registry.npmjs.org/electron/-/electron-2.0.13.tgz", | 3552 | "resolved": "https://registry.npmjs.org/electron/-/electron-4.0.0-beta.9.tgz", |
3553 | "integrity": "sha512-8ouYaLsp0F4sPI7QKgJkkJhrwj1JPSnBwbz6HHA9l6u7WofEt94lV+gHw71KJrDl7UaIkFwlSjyhIjG8lIZqxw==", | 3553 | "integrity": "sha512-BPFkN4BFQy88x2ZHVmzI03i1mUgaQF/uROPb/TlGB/WNAD3v2OvA9Ak9yZ5ADNnwhlR28DtUGs/MuZfDZHZBoQ==", |
3554 | "dev": true, | 3554 | "dev": true, |
3555 | "requires": { | 3555 | "requires": { |
3556 | "@types/node": "^8.0.24", | 3556 | "@types/node": "^8.0.24", |
3557 | "electron-download": "^3.0.1", | 3557 | "electron-download": "^4.1.0", |
3558 | "extract-zip": "^1.0.3" | 3558 | "extract-zip": "^1.0.3" |
3559 | } | 3559 | } |
3560 | }, | 3560 | }, |
@@ -3795,53 +3795,53 @@ | |||
3795 | } | 3795 | } |
3796 | }, | 3796 | }, |
3797 | "electron-download": { | 3797 | "electron-download": { |
3798 | "version": "3.3.0", | 3798 | "version": "4.1.1", |
3799 | "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-3.3.0.tgz", | 3799 | "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz", |
3800 | "integrity": "sha1-LP1U1pZsAZxNSa1l++Zcyc3vaMg=", | 3800 | "integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==", |
3801 | "dev": true, | 3801 | "dev": true, |
3802 | "requires": { | 3802 | "requires": { |
3803 | "debug": "^2.2.0", | 3803 | "debug": "^3.0.0", |
3804 | "fs-extra": "^0.30.0", | 3804 | "env-paths": "^1.0.0", |
3805 | "home-path": "^1.0.1", | 3805 | "fs-extra": "^4.0.1", |
3806 | "minimist": "^1.2.0", | 3806 | "minimist": "^1.2.0", |
3807 | "nugget": "^2.0.0", | 3807 | "nugget": "^2.0.1", |
3808 | "path-exists": "^2.1.0", | 3808 | "path-exists": "^3.0.0", |
3809 | "rc": "^1.1.2", | 3809 | "rc": "^1.2.1", |
3810 | "semver": "^5.3.0", | 3810 | "semver": "^5.4.1", |
3811 | "sumchecker": "^1.2.0" | 3811 | "sumchecker": "^2.0.2" |
3812 | }, | 3812 | }, |
3813 | "dependencies": { | 3813 | "dependencies": { |
3814 | "fs-extra": { | 3814 | "debug": { |
3815 | "version": "0.30.0", | 3815 | "version": "3.2.6", |
3816 | "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", | 3816 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", |
3817 | "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", | 3817 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", |
3818 | "dev": true, | 3818 | "dev": true, |
3819 | "requires": { | 3819 | "requires": { |
3820 | "graceful-fs": "^4.1.2", | 3820 | "ms": "^2.1.1" |
3821 | "jsonfile": "^2.1.0", | ||
3822 | "klaw": "^1.0.0", | ||
3823 | "path-is-absolute": "^1.0.0", | ||
3824 | "rimraf": "^2.2.8" | ||
3825 | } | 3821 | } |
3826 | }, | 3822 | }, |
3827 | "jsonfile": { | 3823 | "fs-extra": { |
3828 | "version": "2.4.0", | 3824 | "version": "4.0.3", |
3829 | "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", | 3825 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", |
3830 | "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", | 3826 | "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", |
3831 | "dev": true, | 3827 | "dev": true, |
3832 | "requires": { | 3828 | "requires": { |
3833 | "graceful-fs": "^4.1.6" | 3829 | "graceful-fs": "^4.1.2", |
3830 | "jsonfile": "^4.0.0", | ||
3831 | "universalify": "^0.1.0" | ||
3834 | } | 3832 | } |
3835 | }, | 3833 | }, |
3836 | "sumchecker": { | 3834 | "ms": { |
3837 | "version": "1.3.1", | 3835 | "version": "2.1.1", |
3838 | "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-1.3.1.tgz", | 3836 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", |
3839 | "integrity": "sha1-ebs7RFbdBPGOvbwNcDodHa7FEF0=", | 3837 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", |
3840 | "dev": true, | 3838 | "dev": true |
3841 | "requires": { | 3839 | }, |
3842 | "debug": "^2.2.0", | 3840 | "path-exists": { |
3843 | "es6-promise": "^4.0.5" | 3841 | "version": "3.0.0", |
3844 | } | 3842 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", |
3843 | "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", | ||
3844 | "dev": true | ||
3845 | } | 3845 | } |
3846 | } | 3846 | } |
3847 | }, | 3847 | }, |
@@ -4193,6 +4193,12 @@ | |||
4193 | "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", | 4193 | "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", |
4194 | "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" | 4194 | "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" |
4195 | }, | 4195 | }, |
4196 | "env-paths": { | ||
4197 | "version": "1.0.0", | ||
4198 | "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", | ||
4199 | "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", | ||
4200 | "dev": true | ||
4201 | }, | ||
4196 | "error-ex": { | 4202 | "error-ex": { |
4197 | "version": "1.3.2", | 4203 | "version": "1.3.2", |
4198 | "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", | 4204 | "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", |
@@ -4246,12 +4252,6 @@ | |||
4246 | "es6-symbol": "^3.1.1" | 4252 | "es6-symbol": "^3.1.1" |
4247 | } | 4253 | } |
4248 | }, | 4254 | }, |
4249 | "es6-promise": { | ||
4250 | "version": "4.2.5", | ||
4251 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", | ||
4252 | "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", | ||
4253 | "dev": true | ||
4254 | }, | ||
4255 | "es6-symbol": { | 4255 | "es6-symbol": { |
4256 | "version": "3.1.1", | 4256 | "version": "3.1.1", |
4257 | "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", | 4257 | "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", |
@@ -6901,12 +6901,6 @@ | |||
6901 | "integrity": "sha1-V6j+JM8zzdUkhgoVgh3cJchmcfs=", | 6901 | "integrity": "sha1-V6j+JM8zzdUkhgoVgh3cJchmcfs=", |
6902 | "dev": true | 6902 | "dev": true |
6903 | }, | 6903 | }, |
6904 | "home-path": { | ||
6905 | "version": "1.0.6", | ||
6906 | "resolved": "https://registry.npmjs.org/home-path/-/home-path-1.0.6.tgz", | ||
6907 | "integrity": "sha512-wo+yjrdAtoXt43Vy92a+0IPCYViiyLAHyp0QVS4xL/tfvVz5sXIW1ubLZk3nhVkD92fQpUMKX+fzMjr5F489vw==", | ||
6908 | "dev": true | ||
6909 | }, | ||
6910 | "homedir-polyfill": { | 6904 | "homedir-polyfill": { |
6911 | "version": "1.0.1", | 6905 | "version": "1.0.1", |
6912 | "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", | 6906 | "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", |
@@ -8046,15 +8040,6 @@ | |||
8046 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", | 8040 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", |
8047 | "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" | 8041 | "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" |
8048 | }, | 8042 | }, |
8049 | "klaw": { | ||
8050 | "version": "1.3.1", | ||
8051 | "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", | ||
8052 | "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", | ||
8053 | "dev": true, | ||
8054 | "requires": { | ||
8055 | "graceful-fs": "^4.1.9" | ||
8056 | } | ||
8057 | }, | ||
8058 | "last-run": { | 8043 | "last-run": { |
8059 | "version": "1.1.1", | 8044 | "version": "1.1.1", |
8060 | "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", | 8045 | "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", |
@@ -9083,7 +9068,7 @@ | |||
9083 | "dependencies": { | 9068 | "dependencies": { |
9084 | "pretty-bytes": { | 9069 | "pretty-bytes": { |
9085 | "version": "1.0.4", | 9070 | "version": "1.0.4", |
9086 | "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", | 9071 | "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", |
9087 | "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", | 9072 | "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", |
9088 | "dev": true, | 9073 | "dev": true, |
9089 | "requires": { | 9074 | "requires": { |
@@ -9776,13 +9761,13 @@ | |||
9776 | }, | 9761 | }, |
9777 | "string_decoder": { | 9762 | "string_decoder": { |
9778 | "version": "0.10.31", | 9763 | "version": "0.10.31", |
9779 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | 9764 | "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", |
9780 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", | 9765 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", |
9781 | "dev": true | 9766 | "dev": true |
9782 | }, | 9767 | }, |
9783 | "through2": { | 9768 | "through2": { |
9784 | "version": "0.2.3", | 9769 | "version": "0.2.3", |
9785 | "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", | 9770 | "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", |
9786 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", | 9771 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", |
9787 | "dev": true, | 9772 | "dev": true, |
9788 | "requires": { | 9773 | "requires": { |
@@ -11330,6 +11315,15 @@ | |||
11330 | "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", | 11315 | "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", |
11331 | "dev": true | 11316 | "dev": true |
11332 | }, | 11317 | }, |
11318 | "sumchecker": { | ||
11319 | "version": "2.0.2", | ||
11320 | "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz", | ||
11321 | "integrity": "sha1-D0LBDl0F2l1C7qPlbDOZo31sWz4=", | ||
11322 | "dev": true, | ||
11323 | "requires": { | ||
11324 | "debug": "^2.2.0" | ||
11325 | } | ||
11326 | }, | ||
11333 | "supports-color": { | 11327 | "supports-color": { |
11334 | "version": "2.0.0", | 11328 | "version": "2.0.0", |
11335 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", | 11329 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", |
diff --git a/package.json b/package.json index 05921d1a1..b7a43ee07 100644 --- a/package.json +++ b/package.json | |||
@@ -98,7 +98,7 @@ | |||
98 | "cross-env": "^5.0.5", | 98 | "cross-env": "^5.0.5", |
99 | "cz-conventional-changelog": "2.1.0", | 99 | "cz-conventional-changelog": "2.1.0", |
100 | "dotenv": "^4.0.0", | 100 | "dotenv": "^4.0.0", |
101 | "electron": "^2.0.13", | 101 | "electron": "4.0.0-beta.9", |
102 | "electron-builder": "20.34.0", | 102 | "electron-builder": "20.34.0", |
103 | "electron-rebuild": "^1.6.0", | 103 | "electron-rebuild": "^1.6.0", |
104 | "eslint": "5.10.0", | 104 | "eslint": "5.10.0", |
diff --git a/src/index.js b/src/index.js index 830166dcf..75da4ff88 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -46,35 +46,69 @@ if (isWindows) { | |||
46 | } | 46 | } |
47 | 47 | ||
48 | // Force single window | 48 | // Force single window |
49 | const isSecondInstance = app.makeSingleInstance((argv) => { | 49 | const gotTheLock = app.requestSingleInstanceLock(); |
50 | if (mainWindow) { | 50 | if (!gotTheLock) { |
51 | if (mainWindow.isMinimized()) mainWindow.restore(); | 51 | app.quit(); |
52 | mainWindow.focus(); | 52 | } else { |
53 | app.on('second-instance', (event, argv) => { | ||
54 | // Someone tried to run a second instance, we should focus our window. | ||
55 | if (mainWindow) { | ||
56 | if (mainWindow.isMinimized()) mainWindow.restore(); | ||
57 | mainWindow.focus(); | ||
53 | 58 | ||
54 | if (process.platform === 'win32') { | 59 | if (isWindows) { |
55 | // Keep only command line / deep linked arguments | 60 | // Keep only command line / deep linked arguments |
56 | const url = argv.slice(1); | 61 | const url = argv.slice(1); |
57 | 62 | ||
58 | if (url) { | 63 | if (url) { |
59 | handleDeepLink(mainWindow, url.toString()); | 64 | handleDeepLink(mainWindow, url.toString()); |
65 | } | ||
60 | } | 66 | } |
61 | } | ||
62 | } | ||
63 | 67 | ||
64 | if (argv.includes('--reset-window')) { | 68 | if (argv.includes('--reset-window')) { |
65 | // Needs to be delayed to not interfere with mainWindow.restore(); | 69 | // Needs to be delayed to not interfere with mainWindow.restore(); |
66 | setTimeout(() => { | 70 | setTimeout(() => { |
67 | debug('Resetting windows via Task'); | 71 | debug('Resetting windows via Task'); |
68 | mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100); | 72 | mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100); |
69 | mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height); | 73 | mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height); |
70 | }, 1); | 74 | }, 1); |
71 | } | 75 | } |
72 | }); | 76 | } |
77 | }); | ||
73 | 78 | ||
74 | if (isSecondInstance) { | 79 | // Create myWindow, load the rest of the app, etc... |
75 | console.log('An instance of Franz is already running. Exiting...'); | 80 | app.on('ready', () => { |
76 | app.exit(); | 81 | }); |
77 | } | 82 | } |
83 | // const isSecondInstance = app.makeSingleInstance((argv) => { | ||
84 | // if (mainWindow) { | ||
85 | // if (mainWindow.isMinimized()) mainWindow.restore(); | ||
86 | // mainWindow.focus(); | ||
87 | |||
88 | // if (process.platform === 'win32') { | ||
89 | // // Keep only command line / deep linked arguments | ||
90 | // const url = argv.slice(1); | ||
91 | |||
92 | // if (url) { | ||
93 | // handleDeepLink(mainWindow, url.toString()); | ||
94 | // } | ||
95 | // } | ||
96 | // } | ||
97 | |||
98 | // if (argv.includes('--reset-window')) { | ||
99 | // // Needs to be delayed to not interfere with mainWindow.restore(); | ||
100 | // setTimeout(() => { | ||
101 | // debug('Resetting windows via Task'); | ||
102 | // mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100); | ||
103 | // mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height); | ||
104 | // }, 1); | ||
105 | // } | ||
106 | // }); | ||
107 | |||
108 | // if (isSecondInstance) { | ||
109 | // console.log('An instance of Franz is already running. Exiting...'); | ||
110 | // app.exit(); | ||
111 | // } | ||
78 | 112 | ||
79 | // Fix Unity indicator issue | 113 | // Fix Unity indicator issue |
80 | // https://github.com/electron/electron/issues/9046 | 114 | // https://github.com/electron/electron/issues/9046 |
diff --git a/src/models/Service.js b/src/models/Service.js index 4cc6102ff..84fded584 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -114,6 +114,13 @@ export default class Service { | |||
114 | }); | 114 | }); |
115 | } | 115 | } |
116 | 116 | ||
117 | @computed get shareWithWebview() { | ||
118 | return { | ||
119 | spellcheckerLanguage: this.spellcheckerLanguage, | ||
120 | isDarkModeEnabled: this.isDarkModeEnabled, | ||
121 | }; | ||
122 | } | ||
123 | |||
117 | @computed get url() { | 124 | @computed get url() { |
118 | if (this.recipe.hasCustomUrl && this.customUrl) { | 125 | if (this.recipe.hasCustomUrl && this.customUrl) { |
119 | let url; | 126 | let url; |
@@ -162,14 +169,14 @@ export default class Service { | |||
162 | return userAgent; | 169 | return userAgent; |
163 | } | 170 | } |
164 | 171 | ||
165 | initializeWebViewEvents(store) { | 172 | initializeWebViewEvents({ handleIPCMessage, openWindow }) { |
166 | this.webview.addEventListener('ipc-message', e => store.actions.service.handleIPCMessage({ | 173 | this.webview.addEventListener('ipc-message', e => handleIPCMessage({ |
167 | serviceId: this.id, | 174 | serviceId: this.id, |
168 | channel: e.channel, | 175 | channel: e.channel, |
169 | args: e.args, | 176 | args: e.args, |
170 | })); | 177 | })); |
171 | 178 | ||
172 | this.webview.addEventListener('new-window', (event, url, frameName, options) => store.actions.service.openWindow({ | 179 | this.webview.addEventListener('new-window', (event, url, frameName, options) => openWindow({ |
173 | event, | 180 | event, |
174 | url, | 181 | url, |
175 | frameName, | 182 | frameName, |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 5b70ca271..b0a926d6a 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -1,5 +1,8 @@ | |||
1 | import { | 1 | import { |
2 | action, reaction, computed, observable, | 2 | action, |
3 | reaction, | ||
4 | computed, | ||
5 | observable, | ||
3 | } from 'mobx'; | 6 | } from 'mobx'; |
4 | import { debounce, remove } from 'lodash'; | 7 | import { debounce, remove } from 'lodash'; |
5 | 8 | ||
@@ -318,12 +321,17 @@ export default class ServicesStore extends Store { | |||
318 | } | 321 | } |
319 | 322 | ||
320 | @action _setWebviewReference({ serviceId, webview }) { | 323 | @action _setWebviewReference({ serviceId, webview }) { |
324 | debug('Set webview reference', serviceId, webview) | ||
321 | const service = this.one(serviceId); | 325 | const service = this.one(serviceId); |
322 | 326 | ||
323 | service.webview = webview; | 327 | service.webview = webview; |
324 | 328 | ||
325 | if (!service.isAttached) { | 329 | if (!service.isAttached) { |
326 | service.initializeWebViewEvents(this); | 330 | debug('Webview is not attached, initializing'); |
331 | service.initializeWebViewEvents({ | ||
332 | handleIPCMessage: this.actions.service.handleIPCMessage, | ||
333 | openWindow: this.actions.service.openWindow, | ||
334 | }); | ||
327 | service.initializeWebViewListener(); | 335 | service.initializeWebViewListener(); |
328 | } | 336 | } |
329 | 337 | ||
@@ -644,14 +652,15 @@ export default class ServicesStore extends Store { | |||
644 | const service = this.one(serviceId); | 652 | const service = this.one(serviceId); |
645 | 653 | ||
646 | if (service.webview) { | 654 | if (service.webview) { |
647 | service.webview.send('initialize-recipe', service); | 655 | debug('Initialize recipe', service.recipe.id, service.name); |
656 | service.webview.send('initialize-recipe', service.shareWithWebview, service.recipe); | ||
648 | } | 657 | } |
649 | } | 658 | } |
650 | 659 | ||
651 | _initRecipePolling(serviceId) { | 660 | _initRecipePolling(serviceId) { |
652 | const service = this.one(serviceId); | 661 | const service = this.one(serviceId); |
653 | 662 | ||
654 | const delay = 1000; | 663 | const delay = 2000; |
655 | 664 | ||
656 | if (service) { | 665 | if (service) { |
657 | if (service.timer !== null) { | 666 | if (service.timer !== null) { |
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 944883899..9aa89ce01 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -42,9 +42,9 @@ class RecipeController { | |||
42 | 42 | ||
43 | async initialize() { | 43 | async initialize() { |
44 | Object.keys(this.ipcEvents).forEach((channel) => { | 44 | Object.keys(this.ipcEvents).forEach((channel) => { |
45 | ipcRenderer.on(channel, (event, data) => { | 45 | ipcRenderer.on(channel, (...args) => { |
46 | debug('Received IPC event for channel', channel, 'with', data); | 46 | debug('Received IPC event for channel', channel, 'with', ...args); |
47 | this[this.ipcEvents[channel]](event, data); | 47 | this[this.ipcEvents[channel]](...args); |
48 | }); | 48 | }); |
49 | }); | 49 | }); |
50 | 50 | ||
@@ -62,17 +62,18 @@ class RecipeController { | |||
62 | autorun(() => this.update()); | 62 | autorun(() => this.update()); |
63 | } | 63 | } |
64 | 64 | ||
65 | loadRecipeModule(event, data) { | 65 | loadRecipeModule(event, config, recipe) { |
66 | debug('loadRecipeModule'); | 66 | debug('loadRecipeModule'); |
67 | const modulePath = path.join(data.recipe.path, 'webview.js'); | 67 | const modulePath = path.join(recipe.path, 'webview.js'); |
68 | debug('module path', modulePath); | ||
68 | // Delete module from cache | 69 | // Delete module from cache |
69 | delete require.cache[require.resolve(modulePath)]; | 70 | delete require.cache[require.resolve(modulePath)]; |
70 | try { | 71 | try { |
71 | // eslint-disable-next-line | 72 | // eslint-disable-next-line |
72 | require(modulePath)(new RecipeWebview(), data); | 73 | require(modulePath)(new RecipeWebview(), {...config, recipe,}); |
73 | debug('Initialize Recipe', data); | 74 | debug('Initialize Recipe', config, recipe); |
74 | 75 | ||
75 | this.settings.service = data; | 76 | this.settings.service = config; |
76 | } catch (err) { | 77 | } catch (err) { |
77 | console.error('Recipe initialization failed', err); | 78 | console.error('Recipe initialization failed', err); |
78 | } | 79 | } |