aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-12-02 00:52:05 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-12-02 00:52:05 +0100
commitfce68f7433537d52e15abf1ffe140e8dcc8afe80 (patch)
tree32b2c8b0c7867434dd2cbcf5e2a1de7a3548dbec /src
parentMerge branch 'develop' into release/5.0.0-beta.19 (diff)
parentCheck if service is enabled before trying to reload (diff)
downloadferdium-app-fce68f7433537d52e15abf1ffe140e8dcc8afe80.tar.gz
ferdium-app-fce68f7433537d52e15abf1ffe140e8dcc8afe80.tar.zst
ferdium-app-fce68f7433537d52e15abf1ffe140e8dcc8afe80.zip
Merge branch 'develop' into release/5.0.0-beta.19
Diffstat (limited to 'src')
-rw-r--r--src/features/delayApp/index.js5
-rw-r--r--src/features/serviceProxy/index.js54
-rw-r--r--src/features/spellchecker/index.js35
-rw-r--r--src/lib/Menu.js2
-rw-r--r--src/stores/ServicesStore.js2
-rw-r--r--src/webview/contextMenu.js2
6 files changed, 44 insertions, 56 deletions
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js
index 3fc0f2570..92d2dcf6a 100644
--- a/src/features/delayApp/index.js
+++ b/src/features/delayApp/index.js
@@ -40,6 +40,11 @@ export default function init(stores) {
40 config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; 40 config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait;
41 41
42 autorun(() => { 42 autorun(() => {
43 if (stores.services.all.length === 0) {
44 shownAfterLaunch = true;
45 return;
46 }
47
43 const diff = moment().diff(timeLastDelay); 48 const diff = moment().diff(timeLastDelay);
44 if ((stores.app.isFocused && diff >= config.delayOffset) || !shownAfterLaunch) { 49 if ((stores.app.isFocused && diff >= config.delayOffset) || !shownAfterLaunch) {
45 debug(`App will be delayed for ${config.delayDuration / 1000}s`); 50 debug(`App will be delayed for ${config.delayDuration / 1000}s`);
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js
index 50dea8c9b..5a74685a4 100644
--- a/src/features/serviceProxy/index.js
+++ b/src/features/serviceProxy/index.js
@@ -13,43 +13,33 @@ export const config = observable({
13}); 13});
14 14
15export default function init(stores) { 15export default function init(stores) {
16 reaction( 16 debug('Initializing `serviceProxy` feature');
17 () => stores.features.features.isServiceProxyEnabled,
18 (enabled, r) => {
19 if (enabled) {
20 debug('Initializing `serviceProxy` feature');
21 17
22 // Dispose the reaction to run this only once 18 autorun(() => {
23 r.dispose(); 19 const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features;
24 20
25 const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features; 21 config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_FEATURES_CONFIG.isServiceProxyEnabled;
22 config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_FEATURES_CONFIG.isServiceProxyPremiumFeature;
26 23
27 config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_FEATURES_CONFIG.isServiceProxyEnabled; 24 const services = stores.services.all;
28 config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_FEATURES_CONFIG.isServiceProxyPremiumFeature; 25 const isPremiumUser = stores.user.data.isPremium;
29 26
30 autorun(() => { 27 services.forEach((service) => {
31 const services = stores.services.all; 28 const s = session.fromPartition(`persist:service-${service.id}`);
32 const isPremiumUser = stores.user.isPremium; 29 let proxyHost = 'direct://';
33 30
34 if (config.isPremium && !isPremiumUser) return; 31 if (config.isEnabled && (isPremiumUser || !config.isPremium)) {
35 32 const serviceProxyConfig = stores.settings.proxy[service.id];
36 services.forEach((service) => { 33
37 const s = session.fromPartition(`persist:service-${service.id}`); 34 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) {
38 let proxyHost = 'direct://'; 35 proxyHost = serviceProxyConfig.host;
39 36 }
40 const serviceProxyConfig = stores.settings.proxy[service.id];
41
42 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) {
43 proxyHost = serviceProxyConfig.host;
44 }
45
46 s.setProxy({ proxyRules: proxyHost }, (e) => {
47 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, e);
48 });
49 });
50 });
51 } 37 }
52 }, 38
53 ); 39 s.setProxy({ proxyRules: proxyHost }, (e) => {
40 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, e);
41 });
42 });
43 });
54} 44}
55 45
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js
index 454096e4e..63506103c 100644
--- a/src/features/spellchecker/index.js
+++ b/src/features/spellchecker/index.js
@@ -1,36 +1,27 @@
1import { autorun, reaction } from 'mobx'; 1import { autorun, observable } from 'mobx';
2 2
3import { DEFAULT_FEATURES_CONFIG } from '../../config'; 3import { DEFAULT_FEATURES_CONFIG } from '../../config';
4 4
5const debug = require('debug')('Franz:feature:spellchecker'); 5const debug = require('debug')('Franz:feature:spellchecker');
6 6
7export const config = { 7export const config = observable({
8 isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, 8 isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature,
9}; 9});
10 10
11export default function init(stores) { 11export default function init(stores) {
12 reaction( 12 debug('Initializing `spellchecker` feature');
13 () => stores.features.features.isSpellcheckerPremiumFeature,
14 (enabled, r) => {
15 debug('Initializing `spellchecker` feature');
16 13
17 // Dispose the reaction to run this only once 14 autorun(() => {
18 r.dispose(); 15 const { isSpellcheckerPremiumFeature } = stores.features.features;
19 16
20 const { isSpellcheckerPremiumFeature } = stores.features.features; 17 config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature;
21 18
22 config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature; 19 if (!stores.user.data.isPremium && config.isPremiumFeature && stores.settings.app.enableSpellchecking) {
20 debug('Override settings.spellcheckerEnabled flag to false');
23 21
24 autorun(() => { 22 Object.assign(stores.settings.app, {
25 if (!stores.user.data.isPremium && config.isPremiumFeature) { 23 enableSpellchecking: false,
26 debug('Override settings.spellcheckerEnabled flag to false');
27
28 Object.assign(stores.settings.all.app, {
29 enableSpellchecking: false,
30 });
31 }
32 }); 24 });
33 }, 25 }
34 ); 26 });
35} 27}
36
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index 9d7df551c..32ec1b207 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -685,7 +685,7 @@ export default class FranzMenu {
685 if (this.stores.user.isLoggedIn) { 685 if (this.stores.user.isLoggedIn) {
686 return services.map((service, i) => ({ 686 return services.map((service, i) => ({
687 label: this._getServiceName(service), 687 label: this._getServiceName(service),
688 accelerator: i <= 9 ? `${cmdKey}+${i + 1}` : null, 688 accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null,
689 type: 'radio', 689 type: 'radio',
690 checked: service.isActive, 690 checked: service.isActive,
691 click: () => { 691 click: () => {
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 8f217ea94..99b091589 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -439,6 +439,8 @@ export default class ServicesStore extends Store {
439 439
440 @action _reload({ serviceId }) { 440 @action _reload({ serviceId }) {
441 const service = this.one(serviceId); 441 const service = this.one(serviceId);
442 if (!service.isEnabled) return;
443
442 service.resetMessageCount(); 444 service.resetMessageCount();
443 445
444 service.webview.loadURL(service.url); 446 service.webview.loadURL(service.url);
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js
index 9b148b220..195306fda 100644
--- a/src/webview/contextMenu.js
+++ b/src/webview/contextMenu.js
@@ -35,7 +35,7 @@ const buildMenuTpl = (props, suggestions) => {
35 id: 'cut', 35 id: 'cut',
36 role: can('Cut') ? 'cut' : '', 36 role: can('Cut') ? 'cut' : '',
37 enabled: can('Cut'), 37 enabled: can('Cut'),
38 visible: props.selectionText.trim(), 38 visible: !!props.selectionText.trim(),
39 }, { 39 }, {
40 id: 'copy', 40 id: 'copy',
41 label: 'Copy', 41 label: 'Copy',