diff options
author | 2019-02-25 16:58:42 +0100 | |
---|---|---|
committer | 2019-02-25 16:58:42 +0100 | |
commit | b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4 (patch) | |
tree | 6b6701cb37e024648b41cc9a6c4174eda35487f9 | |
parent | remove ping (diff) | |
download | ferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.tar.gz ferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.tar.zst ferdium-app-b55ee4d97493f66584f2da0b2f5bb43dcfe25fc4.zip |
replace ms time strings with ms module
-rw-r--r-- | src/components/services/content/WebviewCrashHandler.js | 7 | ||||
-rw-r--r-- | src/components/subscription/SubscriptionPopup.js | 3 | ||||
-rw-r--r-- | src/config.js | 7 | ||||
-rw-r--r-- | src/stores/AppStore.js | 7 | ||||
-rw-r--r-- | src/stores/RecipePreviewsStore.js | 3 | ||||
-rw-r--r-- | src/stores/RequestStore.js | 3 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 5 |
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'; | |||
2 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 3 | import { observer } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 4 | import { defineMessages, intlShape } from 'react-intl'; |
5 | import ms from 'ms'; | ||
5 | 6 | ||
6 | import Button from '../../ui/Button'; | 7 | import 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'; | |||
3 | import { observer } from 'mobx-react'; | 3 | import { observer } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 4 | import { defineMessages, intlShape } from 'react-intl'; |
5 | import Webview from 'react-electron-web-view'; | 5 | import Webview from 'react-electron-web-view'; |
6 | import ms from 'ms'; | ||
6 | 7 | ||
7 | import Button from '../ui/Button'; | 8 | import 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 @@ | |||
1 | import electron from 'electron'; | 1 | import electron from 'electron'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import isDevMode from 'electron-is-dev'; | 3 | import isDevMode from 'electron-is-dev'; |
4 | import ms from 'ms'; | ||
4 | 5 | ||
5 | import { asarPath } from './helpers/asar-helpers'; | 6 | import { asarPath } from './helpers/asar-helpers'; |
6 | 7 | ||
7 | const app = process.type === 'renderer' ? electron.remote.app : electron.app; | 8 | const app = process.type === 'renderer' ? electron.remote.app : electron.app; |
8 | const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; | 9 | const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; |
9 | 10 | ||
10 | export const CHECK_INTERVAL = 1000 * 3600; // How often should we perform checks | 11 | export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks |
11 | export const LOCAL_API = 'http://localhost:3000'; | 12 | export const LOCAL_API = 'http://localhost:3000'; |
12 | export const DEV_API = 'https://dev.franzinfra.com'; | 13 | export const DEV_API = 'https://dev.franzinfra.com'; |
13 | export const LIVE_API = 'https://api.franzinfra.com'; | 14 | export 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'; | |||
7 | import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; | 7 | import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; |
8 | import AutoLaunch from 'auto-launch'; | 8 | import AutoLaunch from 'auto-launch'; |
9 | import prettyBytes from 'pretty-bytes'; | 9 | import prettyBytes from 'pretty-bytes'; |
10 | import ms from 'ms'; | ||
10 | 11 | ||
11 | import Store from './lib/Store'; | 12 | import Store from './lib/Store'; |
12 | import Request from './lib/Request'; | 13 | import 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 @@ | |||
1 | import { action, computed, observable } from 'mobx'; | 1 | import { action, computed, observable } from 'mobx'; |
2 | import { debounce } from 'lodash'; | 2 | import { debounce } from 'lodash'; |
3 | import ms from 'ms'; | ||
3 | 4 | ||
4 | import Store from './lib/Store'; | 5 | import Store from './lib/Store'; |
5 | import CachedRequest from './lib/CachedRequest'; | 6 | import 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 @@ | |||
1 | import { action, computed, observable } from 'mobx'; | 1 | import { action, computed, observable } from 'mobx'; |
2 | import ms from 'ms'; | ||
2 | 3 | ||
3 | import Store from './lib/Store'; | 4 | import 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'; |
7 | import { debounce, remove } from 'lodash'; | 7 | import { debounce, remove } from 'lodash'; |
8 | import ms from 'ms'; | ||
8 | 9 | ||
9 | import Store from './lib/Store'; | 10 | import Store from './lib/Store'; |
10 | import Request from './lib/Request'; | 11 | import 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; |