diff options
author | 2021-07-03 07:09:05 +0530 | |
---|---|---|
committer | 2021-07-03 07:09:05 +0530 | |
commit | 83676cec9ce8e41d5e88e7d06a17dd8194e3593e (patch) | |
tree | a73eb8b64a20530ee3c44f1901c9daa2a069f12a /src/config.js | |
parent | Update submodules, browserslist data updates and linter fixes [skip ci] (diff) | |
download | ferdium-app-83676cec9ce8e41d5e88e7d06a17dd8194e3593e.tar.gz ferdium-app-83676cec9ce8e41d5e88e7d06a17dd8194e3593e.tar.zst ferdium-app-83676cec9ce8e41d5e88e7d06a17dd8194e3593e.zip |
Minor refactoring to move all runtime configs from 'config.js' into 'environment.js'. (#1588)
Diffstat (limited to 'src/config.js')
-rw-r--r-- | src/config.js | 102 |
1 files changed, 2 insertions, 100 deletions
diff --git a/src/config.js b/src/config.js index d96a6068b..089ec1a8d 100644 --- a/src/config.js +++ b/src/config.js | |||
@@ -1,9 +1,6 @@ | |||
1 | import ms from 'ms'; | 1 | // Note: This file has now become devoid of all references to values deduced from the runtime process - all those now live in the `environment.js` file |
2 | import path from 'path'; | ||
3 | import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; | ||
4 | import { asarPath } from './helpers/asar-helpers'; | ||
5 | 2 | ||
6 | const { app, nativeTheme } = process.type === 'renderer' ? require('@electron/remote') : require('electron'); | 3 | import ms from 'ms'; |
7 | 4 | ||
8 | export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks | 5 | export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks |
9 | 6 | ||
@@ -122,61 +119,6 @@ export const ICON_SIZES = { | |||
122 | // The bias should always be the "Normal icons" value | 119 | // The bias should always be the "Normal icons" value |
123 | export const iconSizeBias = 20; | 120 | export const iconSizeBias = 20; |
124 | 121 | ||
125 | export const DEFAULT_APP_SETTINGS = { | ||
126 | autoLaunchInBackground: false, | ||
127 | runInBackground: true, | ||
128 | reloadAfterResume: true, | ||
129 | enableSystemTray: true, | ||
130 | startMinimized: false, | ||
131 | minimizeToSystemTray: false, | ||
132 | closeToSystemTray: false, | ||
133 | privateNotifications: false, | ||
134 | clipboardNotifications: true, | ||
135 | notifyTaskBarOnMessage: false, | ||
136 | showDisabledServices: true, | ||
137 | showMessageBadgeWhenMuted: true, | ||
138 | showDragArea: false, | ||
139 | enableSpellchecking: true, | ||
140 | spellcheckerLanguage: 'en-us', | ||
141 | darkMode: process.platform === 'darwin' ? nativeTheme.shouldUseDarkColors : false, // We can't use refs from `./environment` at this time | ||
142 | locale: '', | ||
143 | fallbackLocale: 'en-US', | ||
144 | beta: false, | ||
145 | isAppMuted: false, | ||
146 | enableGPUAcceleration: true, | ||
147 | serviceLimit: 5, | ||
148 | |||
149 | // Ferdi specific options | ||
150 | server: LIVE_FERDI_API, | ||
151 | predefinedTodoServer: DEFAULT_TODO_SERVICE, | ||
152 | autohideMenuBar: false, | ||
153 | lockingFeatureEnabled: false, | ||
154 | locked: false, | ||
155 | lockedPassword: '', | ||
156 | useTouchIdToUnlock: true, | ||
157 | scheduledDNDEnabled: false, | ||
158 | scheduledDNDStart: '17:00', | ||
159 | scheduledDNDEnd: '09:00', | ||
160 | hibernate: false, | ||
161 | hibernateOnStartup: true, | ||
162 | hibernationStrategy: 300, | ||
163 | inactivityLock: 0, | ||
164 | automaticUpdates: true, | ||
165 | showServiceNavigationBar: false, | ||
166 | universalDarkMode: true, | ||
167 | userAgentPref: '', | ||
168 | adaptableDarkMode: true, | ||
169 | accentColor: DEFAULT_ACCENT_COLOR, | ||
170 | serviceRibbonWidth: 68, | ||
171 | iconSize: iconSizeBias, | ||
172 | sentry: false, | ||
173 | nightly: false, | ||
174 | navigationBarBehaviour: 'custom', | ||
175 | searchEngine: SEARCH_ENGINE_DDG, | ||
176 | useVerticalStyle: false, | ||
177 | alwaysShowWorkspaces: false, | ||
178 | }; | ||
179 | |||
180 | export const DEFAULT_FEATURES_CONFIG = { | 122 | export const DEFAULT_FEATURES_CONFIG = { |
181 | isSpellcheckerIncludedInCurrentPlan: true, | 123 | isSpellcheckerIncludedInCurrentPlan: true, |
182 | needToWaitToProceed: false, | 124 | needToWaitToProceed: false, |
@@ -217,45 +159,6 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [ | |||
217 | export const LOCAL_SERVER = 'You are using Ferdi without a server'; | 159 | export const LOCAL_SERVER = 'You are using Ferdi without a server'; |
218 | export const SERVER_NOT_LOADED = 'Ferdi::SERVER_NOT_LOADED'; | 160 | export const SERVER_NOT_LOADED = 'Ferdi::SERVER_NOT_LOADED'; |
219 | 161 | ||
220 | // TODO: This seems to be duplicated between here and 'index.js' | ||
221 | // Set app directory before loading user modules | ||
222 | if (process.env.FERDI_APPDATA_DIR != null) { | ||
223 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | ||
224 | app.setPath('userData', path.join(app.getPath('appData'))); | ||
225 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { | ||
226 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); | ||
227 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}AppData`)); | ||
228 | } else if (process.platform === 'win32') { | ||
229 | app.setPath('appData', process.env.APPDATA); | ||
230 | app.setPath('userData', path.join(app.getPath('appData'), app.name)); | ||
231 | } | ||
232 | |||
233 | const ELECTRON_IS_DEV_VAR = 'ELECTRON_IS_DEV'; | ||
234 | const NODE_ENV_VAR = 'NODE_ENV'; | ||
235 | |||
236 | // TODO Move this to environment.js and remove the re-export from there. | ||
237 | export const isDevMode = (() => { | ||
238 | const isEnvVarSet = name => name in process.env; | ||
239 | if (isEnvVarSet(ELECTRON_IS_DEV_VAR)) { | ||
240 | // Copied from https://github.com/sindresorhus/electron-is-dev/blob/f05330b856782dac7987b10859bfd95ea6a187a6/index.js | ||
241 | // but electron-is-dev breaks in a renderer process, so we use the app import from above instead. | ||
242 | const electronIsDev = process.env[ELECTRON_IS_DEV_VAR]; | ||
243 | return electronIsDev === 'true' || Number.parseInt(electronIsDev, 10) === 1; | ||
244 | } | ||
245 | if (isEnvVarSet(NODE_ENV_VAR)) { | ||
246 | return process.env[NODE_ENV_VAR] === 'development'; | ||
247 | } | ||
248 | return !app.isPackaged; | ||
249 | })(); | ||
250 | if (isDevMode) { | ||
251 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}Dev`)); | ||
252 | } | ||
253 | |||
254 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); | ||
255 | |||
256 | // Replacing app.asar is not beautiful but unfortunately necessary | ||
257 | export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes')); | ||
258 | |||
259 | export const ALLOWED_PROTOCOLS = [ | 162 | export const ALLOWED_PROTOCOLS = [ |
260 | 'https:', | 163 | 'https:', |
261 | 'http:', | 164 | 'http:', |
@@ -285,7 +188,6 @@ export const PLANS_MAPPING = { | |||
285 | free: PLANS.FREE, | 188 | free: PLANS.FREE, |
286 | }; | 189 | }; |
287 | 190 | ||
288 | |||
289 | export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false; | 191 | export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false; |
290 | 192 | ||
291 | export const DEFAULT_SERVICE_LIMIT = 3; | 193 | export const DEFAULT_SERVICE_LIMIT = 3; |