aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/delayApp/Component.js8
-rw-r--r--src/features/delayApp/index.js6
-rw-r--r--src/features/delayApp/styles.js49
-rw-r--r--src/features/serviceProxy/index.js56
-rw-r--r--src/features/spellchecker/index.js38
-rw-r--r--src/features/spellchecker/styles.js26
6 files changed, 151 insertions, 32 deletions
diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js
index 2bfa1162e..403340c7b 100644
--- a/src/features/delayApp/Component.js
+++ b/src/features/delayApp/Component.js
@@ -24,7 +24,7 @@ const messages = defineMessages({
24 }, 24 },
25}); 25});
26 26
27export default @inject('actions') @observer @injectSheet(styles) class DelayApp extends Component { 27export default @inject('actions') @injectSheet(styles) @observer class DelayApp extends Component {
28 static propTypes = { 28 static propTypes = {
29 // eslint-disable-next-line 29 // eslint-disable-next-line
30 classes: PropTypes.object.isRequired, 30 classes: PropTypes.object.isRequired,
@@ -39,8 +39,6 @@ export default @inject('actions') @observer @injectSheet(styles) class DelayApp
39 } 39 }
40 40
41 componentDidMount() { 41 componentDidMount() {
42 // const { reload } = this.props;
43
44 this.countdownInterval = setInterval(() => { 42 this.countdownInterval = setInterval(() => {
45 this.setState({ 43 this.setState({
46 countdown: this.state.countdown - this.countdownIntervalTimeout, 44 countdown: this.state.countdown - this.countdownIntervalTimeout,
@@ -53,6 +51,10 @@ export default @inject('actions') @observer @injectSheet(styles) class DelayApp
53 }, this.countdownIntervalTimeout); 51 }, this.countdownIntervalTimeout);
54 } 52 }
55 53
54 componentWillUnmount() {
55 clearInterval(this.countdownInterval);
56 }
57
56 countdownInterval = null; 58 countdownInterval = null;
57 countdownIntervalTimeout = 1000; 59 countdownIntervalTimeout = 1000;
58 60
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js
index a3cce03ee..334433df8 100644
--- a/src/features/delayApp/index.js
+++ b/src/features/delayApp/index.js
@@ -38,8 +38,8 @@ export default function init(stores) {
38 let shownAfterLaunch = false; 38 let shownAfterLaunch = false;
39 let timeLastDelay = moment(); 39 let timeLastDelay = moment();
40 40
41 config.delayOffset = globalConfig.delayOffset || DEFAULT_DELAY_OFFSET; 41 config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_DELAY_OFFSET;
42 config.delayDuration = globalConfig.wait || DEFAULT_DELAY_DURATION; 42 config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_DELAY_DURATION;
43 43
44 autorun(() => { 44 autorun(() => {
45 const diff = moment().diff(timeLastDelay); 45 const diff = moment().diff(timeLastDelay);
@@ -63,5 +63,5 @@ export default function init(stores) {
63 ); 63 );
64} 64}
65 65
66export const component = DelayAppComponent; 66export const Component = DelayAppComponent;
67 67
diff --git a/src/features/delayApp/styles.js b/src/features/delayApp/styles.js
index 097368d9a..5c214cfdf 100644
--- a/src/features/delayApp/styles.js
+++ b/src/features/delayApp/styles.js
@@ -1,26 +1,23 @@
1export default (theme) => { 1export default theme => ({
2 console.log(theme); 2 container: {
3 return ({ 3 background: theme.colorBackground,
4 container: { 4 position: 'absolute',
5 background: theme.colorBackground, 5 top: 0,
6 position: 'absolute', 6 width: '100%',
7 top: 0, 7 display: 'flex',
8 width: '100%', 8 'flex-direction': 'column',
9 display: 'flex', 9 'align-items': 'center',
10 'flex-direction': 'column', 10 'justify-content': 'center',
11 'align-items': 'center', 11 'z-index': 150,
12 'justify-content': 'center', 12 },
13 'z-index': 150, 13 headline: {
14 }, 14 color: theme.colorHeadline,
15 headline: { 15 margin: [25, 0, 40],
16 color: theme.colorHeadline, 16 'max-width': 500,
17 margin: [25, 0, 40], 17 'text-align': 'center',
18 'max-width': 500, 18 'line-height': '1.3em',
19 'text-align': 'center', 19 },
20 'line-height': '1.3em', 20 button: {
21 }, 21 margin: [40, 0, 20],
22 button: { 22 },
23 margin: [40, 0, 20], 23});
24 },
25 });
26};
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js
new file mode 100644
index 000000000..edb1c9367
--- /dev/null
+++ b/src/features/serviceProxy/index.js
@@ -0,0 +1,56 @@
1import { autorun, reaction, observable } from 'mobx';
2import { remote } from 'electron';
3
4const { session } = remote;
5
6const debug = require('debug')('Franz:feature:serviceProxy');
7
8const DEFAULT_ENABLED = false;
9const DEFAULT_IS_PREMIUM = true;
10
11export const config = observable({
12 isEnabled: DEFAULT_ENABLED,
13 isPremium: DEFAULT_IS_PREMIUM,
14});
15
16export default function init(stores) {
17 reaction(
18 () => stores.features.features.isServiceProxyEnabled,
19 (enabled, r) => {
20 if (enabled) {
21 debug('Initializing `serviceProxy` feature');
22
23 // Dispose the reaction to run this only once
24 r.dispose();
25
26 const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features;
27
28 config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_ENABLED;
29 config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_IS_PREMIUM;
30
31 autorun(() => {
32 const services = stores.services.all;
33 const isPremiumUser = stores.user.isPremium;
34
35 if (config.isPremium && !isPremiumUser) return;
36
37 services.forEach((service) => {
38 const s = session.fromPartition(`persist:service-${service.id}`);
39 let proxyHost = 'direct://';
40
41 const serviceProxyConfig = stores.settings.proxy[service.id];
42
43 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) {
44 proxyHost = serviceProxyConfig.host;
45 }
46
47 s.setProxy({ proxyRules: proxyHost }, (e) => {
48 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, e);
49 });
50 });
51 });
52 }
53 },
54 );
55}
56
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js
new file mode 100644
index 000000000..8b3fb7e00
--- /dev/null
+++ b/src/features/spellchecker/index.js
@@ -0,0 +1,38 @@
1import { autorun, reaction } from 'mobx';
2
3const debug = require('debug')('Franz:feature:spellchecker');
4
5const DEFAULT_IS_PREMIUM_FEATURE = true;
6
7export const config = {
8 isPremiumFeature: DEFAULT_IS_PREMIUM_FEATURE,
9};
10
11export default function init(stores) {
12 reaction(
13 () => stores.features.features.isSpellcheckerPremiumFeature,
14 (enabled, r) => {
15 if (enabled) {
16 debug('Initializing `spellchecker` feature');
17
18 // Dispose the reaction to run this only once
19 r.dispose();
20
21 const { isSpellcheckerPremiumFeature } = stores.features.features;
22
23 config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_IS_PREMIUM_FEATURE;
24
25 autorun(() => {
26 if (!stores.user.data.isPremium && config.isPremiumFeature) {
27 debug('Override settings.spellcheckerEnabled flag to false');
28
29 Object.assign(stores.settings.all.app, {
30 enableSpellchecker: false,
31 });
32 }
33 });
34 }
35 },
36 );
37}
38
diff --git a/src/features/spellchecker/styles.js b/src/features/spellchecker/styles.js
new file mode 100644
index 000000000..097368d9a
--- /dev/null
+++ b/src/features/spellchecker/styles.js
@@ -0,0 +1,26 @@
1export default (theme) => {
2 console.log(theme);
3 return ({
4 container: {
5 background: theme.colorBackground,
6 position: 'absolute',
7 top: 0,
8 width: '100%',
9 display: 'flex',
10 'flex-direction': 'column',
11 'align-items': 'center',
12 'justify-content': 'center',
13 'z-index': 150,
14 },
15 headline: {
16 color: theme.colorHeadline,
17 margin: [25, 0, 40],
18 'max-width': 500,
19 'text-align': 'center',
20 'line-height': '1.3em',
21 },
22 button: {
23 margin: [40, 0, 20],
24 },
25 });
26};