aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-02-25 16:58:42 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-02-25 16:58:42 +0100
commitb55ee4d97493f66584f2da0b2f5bb43dcfe25fc4 (patch)
tree6b6701cb37e024648b41cc9a6c4174eda35487f9 /src
parentremove ping (diff)
downloadferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.tar.gz
ferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.tar.zst
ferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.zip
replace ms time strings with ms module
Diffstat (limited to 'src')
-rw-r--r--src/components/services/content/WebviewCrashHandler.js7
-rw-r--r--src/components/subscription/SubscriptionPopup.js3
-rw-r--r--src/config.js7
-rw-r--r--src/stores/AppStore.js7
-rw-r--r--src/stores/RecipePreviewsStore.js3
-rw-r--r--src/stores/RequestStore.js3
-rw-r--r--src/stores/ServicesStore.js5
7 files changed, 21 insertions, 14 deletions
diff --git a/src/components/services/content/WebviewCrashHandler.js b/src/components/services/content/WebviewCrashHandler.js
index 42bc3c877..7a69dba87 100644
--- a/src/components/services/content/WebviewCrashHandler.js
+++ b/src/components/services/content/WebviewCrashHandler.js
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
2import PropTypes from 'prop-types'; 2import PropTypes from 'prop-types';
3import { observer } from 'mobx-react'; 3import { observer } from 'mobx-react';
4import { defineMessages, intlShape } from 'react-intl'; 4import { defineMessages, intlShape } from 'react-intl';
5import ms from 'ms';
5 6
6import Button from '../../ui/Button'; 7import Button from '../../ui/Button';
7 8
@@ -35,12 +36,12 @@ export default @observer class WebviewCrashHandler extends Component {
35 }; 36 };
36 37
37 state = { 38 state = {
38 countdown: 10000, 39 countdown: ms('10s'),
39 } 40 }
40 41
41 countdownInterval = null; 42 countdownInterval = null;
42 43
43 countdownIntervalTimeout = 1000; 44 countdownIntervalTimeout = ms('1s');
44 45
45 46
46 componentDidMount() { 47 componentDidMount() {
@@ -75,7 +76,7 @@ export default @observer class WebviewCrashHandler extends Component {
75 <p className="footnote"> 76 <p className="footnote">
76 {intl.formatMessage(messages.autoReload, { 77 {intl.formatMessage(messages.autoReload, {
77 name, 78 name,
78 seconds: this.state.countdown / 1000, 79 seconds: this.state.countdown / ms('1s'),
79 })} 80 })}
80 </p> 81 </p>
81 </div> 82 </div>
diff --git a/src/components/subscription/SubscriptionPopup.js b/src/components/subscription/SubscriptionPopup.js
index b5d7c4b2d..0f6f0260f 100644
--- a/src/components/subscription/SubscriptionPopup.js
+++ b/src/components/subscription/SubscriptionPopup.js
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3import { observer } from 'mobx-react'; 3import { observer } from 'mobx-react';
4import { defineMessages, intlShape } from 'react-intl'; 4import { defineMessages, intlShape } from 'react-intl';
5import Webview from 'react-electron-web-view'; 5import Webview from 'react-electron-web-view';
6import ms from 'ms';
6 7
7import Button from '../ui/Button'; 8import Button from '../ui/Button';
8 9
@@ -42,7 +43,7 @@ export default @observer class SubscriptionPopup extends Component {
42 43
43 setTimeout(() => { 44 setTimeout(() => {
44 this.props.closeWindow(); 45 this.props.closeWindow();
45 }, 4000); 46 }, ms('4s'));
46 } 47 }
47 48
48 render() { 49 render() {
diff --git a/src/config.js b/src/config.js
index 0b377f62d..a782ad667 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,13 +1,14 @@
1import electron from 'electron'; 1import electron from 'electron';
2import path from 'path'; 2import path from 'path';
3import isDevMode from 'electron-is-dev'; 3import isDevMode from 'electron-is-dev';
4import ms from 'ms';
4 5
5import { asarPath } from './helpers/asar-helpers'; 6import { asarPath } from './helpers/asar-helpers';
6 7
7const app = process.type === 'renderer' ? electron.remote.app : electron.app; 8const app = process.type === 'renderer' ? electron.remote.app : electron.app;
8const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; 9const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences;
9 10
10export const CHECK_INTERVAL = 1000 * 3600; // How often should we perform checks 11export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks
11export const LOCAL_API = 'http://localhost:3000'; 12export const LOCAL_API = 'http://localhost:3000';
12export const DEV_API = 'https://dev.franzinfra.com'; 13export const DEV_API = 'https://dev.franzinfra.com';
13export const LIVE_API = 'https://api.franzinfra.com'; 14export const LIVE_API = 'https://api.franzinfra.com';
@@ -35,8 +36,8 @@ export const DEFAULT_FEATURES_CONFIG = {
35 isSpellcheckerPremiumFeature: false, 36 isSpellcheckerPremiumFeature: false,
36 needToWaitToProceed: false, 37 needToWaitToProceed: false,
37 needToWaitToProceedConfig: { 38 needToWaitToProceedConfig: {
38 delayOffset: 3600000, 39 delayOffset: ms('1h'),
39 wait: 10000, 40 wait: ms('10s'),
40 }, 41 },
41 isServiceProxyEnabled: false, 42 isServiceProxyEnabled: false,
42 isServiceProxyPremiumFeature: true, 43 isServiceProxyPremiumFeature: true,
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index d90f32744..168aa7e48 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -7,6 +7,7 @@ import key from 'keymaster';
7import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; 7import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
8import AutoLaunch from 'auto-launch'; 8import AutoLaunch from 'auto-launch';
9import prettyBytes from 'pretty-bytes'; 9import prettyBytes from 'pretty-bytes';
10import ms from 'ms';
10 11
11import Store from './lib/Store'; 12import Store from './lib/Store';
12import Request from './lib/Request'; 13import Request from './lib/Request';
@@ -112,12 +113,12 @@ export default class AppStore extends Store {
112 // Check if system is muted 113 // Check if system is muted
113 // There are no events to subscribe so we need to poll everey 5s 114 // There are no events to subscribe so we need to poll everey 5s
114 this._systemDND(); 115 this._systemDND();
115 setInterval(() => this._systemDND(), 5000); 116 setInterval(() => this._systemDND(), ms('5s'));
116 117
117 // Check for updates once every 4 hours 118 // Check for updates once every 4 hours
118 setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); 119 setInterval(() => this._checkForUpdates(), CHECK_INTERVAL);
119 // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) 120 // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues)
120 setTimeout(() => this._checkForUpdates(), 30000); 121 setTimeout(() => this._checkForUpdates(), ms('30s'));
121 ipcRenderer.on('autoUpdate', (event, data) => { 122 ipcRenderer.on('autoUpdate', (event, data) => {
122 if (data.available) { 123 if (data.available) {
123 this.updateStatus = this.updateStatusTypes.AVAILABLE; 124 this.updateStatus = this.updateStatusTypes.AVAILABLE;
@@ -316,7 +317,7 @@ export default class AppStore extends Store {
316 } else { 317 } else {
317 const deltaTime = moment().diff(this.timeOfflineStart); 318 const deltaTime = moment().diff(this.timeOfflineStart);
318 319
319 if (deltaTime > 30 * 60 * 1000) { 320 if (deltaTime > ms('30m')) {
320 this.actions.service.reloadAll(); 321 this.actions.service.reloadAll();
321 } 322 }
322 } 323 }
diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js
index 10b2928e3..382820d58 100644
--- a/src/stores/RecipePreviewsStore.js
+++ b/src/stores/RecipePreviewsStore.js
@@ -1,5 +1,6 @@
1import { action, computed, observable } from 'mobx'; 1import { action, computed, observable } from 'mobx';
2import { debounce } from 'lodash'; 2import { debounce } from 'lodash';
3import ms from 'ms';
3 4
4import Store from './lib/Store'; 5import Store from './lib/Store';
5import CachedRequest from './lib/CachedRequest'; 6import CachedRequest from './lib/CachedRequest';
@@ -48,5 +49,5 @@ export default class RecipePreviewsStore extends Store {
48 // Helper 49 // Helper
49 _analyticsSearch = debounce((needle) => { 50 _analyticsSearch = debounce((needle) => {
50 gaEvent('Recipe', 'search', needle); 51 gaEvent('Recipe', 'search', needle);
51 }, 3000); 52 }, ms('3s'));
52} 53}
diff --git a/src/stores/RequestStore.js b/src/stores/RequestStore.js
index 2629e0a38..9254e3223 100644
--- a/src/stores/RequestStore.js
+++ b/src/stores/RequestStore.js
@@ -1,4 +1,5 @@
1import { action, computed, observable } from 'mobx'; 1import { action, computed, observable } from 'mobx';
2import ms from 'ms';
2 3
3import Store from './lib/Store'; 4import Store from './lib/Store';
4 5
@@ -13,7 +14,7 @@ export default class RequestStore extends Store {
13 14
14 retries = 0; 15 retries = 0;
15 16
16 retryDelay = 2000; 17 retryDelay = ms('2s');
17 18
18 constructor(...args) { 19 constructor(...args) {
19 super(...args); 20 super(...args);
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index efd57a09d..c63bef196 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -5,6 +5,7 @@ import {
5 observable, 5 observable,
6} from 'mobx'; 6} from 'mobx';
7import { debounce, remove } from 'lodash'; 7import { debounce, remove } from 'lodash';
8import ms from 'ms';
8 9
9import Store from './lib/Store'; 10import Store from './lib/Store';
10import Request from './lib/Request'; 11import Request from './lib/Request';
@@ -679,7 +680,7 @@ export default class ServicesStore extends Store {
679 _initRecipePolling(serviceId) { 680 _initRecipePolling(serviceId) {
680 const service = this.one(serviceId); 681 const service = this.one(serviceId);
681 682
682 const delay = 2000; 683 const delay = ms('2s');
683 684
684 if (service) { 685 if (service) {
685 if (service.timer !== null) { 686 if (service.timer !== null) {
@@ -700,7 +701,7 @@ export default class ServicesStore extends Store {
700 701
701 _reorderAnalytics = debounce(() => { 702 _reorderAnalytics = debounce(() => {
702 gaEvent('Service', 'order'); 703 gaEvent('Service', 'order');
703 }, 5000); 704 }, ms('5s'));
704 705
705 _wrapIndex(index, delta, size) { 706 _wrapIndex(index, delta, size) {
706 return (((index + delta) % size) + size) % size; 707 return (((index + delta) % size) + size) % size;