From d4afc1eec9706d0027ad4b44421f8868688d1969 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Fri, 1 Oct 2021 22:13:42 +0530 Subject: refactor: move 'DEFAULT_APP_SETTINGS' from 'environment' to 'config' since it doesn't depend on the running process any more. --- .../settings/settings/EditSettingsForm.js | 3 +- src/config.ts | 58 +++++++++++++++++++ src/containers/settings/EditSettingsScreen.js | 3 +- src/environment.ts | 67 +--------------------- src/features/appearance/index.ts | 3 +- src/index.js | 3 +- .../app/Controllers/Http/UserController.js | 2 +- src/stores/AppStore.js | 3 +- src/stores/SettingsStore.js | 3 +- src/webview/recipe.js | 2 +- 10 files changed, 69 insertions(+), 78 deletions(-) diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 819d0a9e6..123ab4c2d 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js @@ -12,9 +12,8 @@ import ToggleRaw from '../../ui/ToggleRaw'; import Select from '../../ui/Select'; import Input from '../../ui/Input'; -import { FRANZ_TRANSLATION, GITHUB_FRANZ_URL } from '../../../config'; +import { DEFAULT_APP_SETTINGS, FRANZ_TRANSLATION, GITHUB_FRANZ_URL } from '../../../config'; import { - DEFAULT_APP_SETTINGS, isMac, isWindows, lockFerdiShortcutKey, diff --git a/src/config.ts b/src/config.ts index 667b0a962..fe9145021 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,6 +2,8 @@ import ms from 'ms'; +import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; + export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks export const LOCAL_HOSTNAME = 'localhost'; @@ -176,3 +178,59 @@ export const TODOS_PARTITION_ID = 'persist:todos'; export const CUSTOM_WEBSITE_RECIPE_ID = 'franz-custom-website'; export const DEFAULT_SERVICE_ORDER = 99; // something high enough that it gets added to the end of the already-added services on the left sidebar + +export const DEFAULT_APP_SETTINGS = { + autoLaunchInBackground: false, + runInBackground: true, + reloadAfterResume: true, + enableSystemTray: true, + startMinimized: false, + confirmOnQuit: false, + minimizeToSystemTray: false, + closeToSystemTray: false, + privateNotifications: false, + clipboardNotifications: true, + notifyTaskBarOnMessage: false, + showDisabledServices: true, + showMessageBadgeWhenMuted: true, + showDragArea: false, + enableSpellchecking: true, + spellcheckerLanguage: 'en-us', + darkMode: false, + splitMode: false, + locale: '', + fallbackLocale: 'en-US', + beta: false, + isAppMuted: false, + enableGPUAcceleration: true, + + // Ferdi specific options + server: LIVE_FERDI_API, + predefinedTodoServer: DEFAULT_TODO_SERVICE, + autohideMenuBar: false, + lockingFeatureEnabled: false, + locked: false, + lockedPassword: '', + useTouchIdToUnlock: true, + scheduledDNDEnabled: false, + scheduledDNDStart: '17:00', + scheduledDNDEnd: '09:00', + hibernateOnStartup: true, + hibernationStrategy: '300', // seconds + wakeUpStrategy: '300', // seconds + inactivityLock: 0, + automaticUpdates: true, + universalDarkMode: true, + userAgentPref: '', + adaptableDarkMode: true, + accentColor: DEFAULT_ACCENT_COLOR, + serviceRibbonWidth: 68, + iconSize: iconSizeBias, + sentry: false, + nightly: false, + navigationBarBehaviour: 'custom', + searchEngine: SEARCH_ENGINE_DDG, + useVerticalStyle: false, + alwaysShowWorkspaces: false, + liftSingleInstanceLock: false, +}; diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 36b9e949b..1b05644f9 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js @@ -10,6 +10,7 @@ import TodosStore from '../../features/todos/store'; import Form from '../../lib/Form'; import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; import { + DEFAULT_APP_SETTINGS, HIBERNATION_STRATEGIES, SIDEBAR_WIDTH, ICON_SIZES, @@ -20,7 +21,7 @@ import { DEFAULT_IS_FEATURE_ENABLED_BY_USER, WAKE_UP_STRATEGIES, } from '../../config'; -import { DEFAULT_APP_SETTINGS, isMac } from '../../environment'; +import { isMac } from '../../environment'; import { getSelectOptions } from '../../helpers/i18n-helpers'; import { hash } from '../../helpers/password-helpers'; diff --git a/src/environment.ts b/src/environment.ts index 99002367f..ce2a77e7a 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -1,13 +1,6 @@ -import os from 'os'; - -import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; +// Note: This file has now become devoid of all references to values deduced from the remote process - all those now live in the `environment-remote.js` file -import { - LIVE_FERDI_API, - DEFAULT_TODO_SERVICE, - SEARCH_ENGINE_DDG, - iconSizeBias, -} from './config'; +import os from 'os'; export const isMac = process.platform === 'darwin'; export const isWindows = process.platform === 'win32'; @@ -47,59 +40,3 @@ export const addNewServiceShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+N`; export const settingsShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+${isMac ? ',' : 'P'}`; - -export const DEFAULT_APP_SETTINGS = { - autoLaunchInBackground: false, - runInBackground: true, - reloadAfterResume: true, - enableSystemTray: true, - startMinimized: false, - confirmOnQuit: false, - minimizeToSystemTray: false, - closeToSystemTray: false, - privateNotifications: false, - clipboardNotifications: true, - notifyTaskBarOnMessage: false, - showDisabledServices: true, - showMessageBadgeWhenMuted: true, - showDragArea: false, - enableSpellchecking: true, - spellcheckerLanguage: 'en-us', - darkMode: false, - splitMode: false, - locale: '', - fallbackLocale: 'en-US', - beta: false, - isAppMuted: false, - enableGPUAcceleration: true, - - // Ferdi specific options - server: LIVE_FERDI_API, - predefinedTodoServer: DEFAULT_TODO_SERVICE, - autohideMenuBar: false, - lockingFeatureEnabled: false, - locked: false, - lockedPassword: '', - useTouchIdToUnlock: true, - scheduledDNDEnabled: false, - scheduledDNDStart: '17:00', - scheduledDNDEnd: '09:00', - hibernateOnStartup: true, - hibernationStrategy: '300', // seconds - wakeUpStrategy: '300', // seconds - inactivityLock: 0, - automaticUpdates: true, - universalDarkMode: true, - userAgentPref: '', - adaptableDarkMode: true, - accentColor: DEFAULT_ACCENT_COLOR, - serviceRibbonWidth: 68, - iconSize: iconSizeBias, - sentry: false, - nightly: false, - navigationBarBehaviour: 'custom', - searchEngine: SEARCH_ENGINE_DDG, - useVerticalStyle: false, - alwaysShowWorkspaces: false, - liftSingleInstanceLock: false, -}; diff --git a/src/features/appearance/index.ts b/src/features/appearance/index.ts index cb2f937eb..bb93507dc 100644 --- a/src/features/appearance/index.ts +++ b/src/features/appearance/index.ts @@ -1,7 +1,6 @@ import color from 'color'; import { reaction } from 'mobx'; -import { iconSizeBias } from '../../config'; -import { DEFAULT_APP_SETTINGS } from '../../environment'; +import { DEFAULT_APP_SETTINGS, iconSizeBias } from '../../config'; const STYLE_ELEMENT_ID = 'custom-appearance-style'; diff --git a/src/index.js b/src/index.js index 6035d08a4..ed37134c9 100644 --- a/src/index.js +++ b/src/index.js @@ -10,10 +10,9 @@ import ms from 'ms'; require('@electron/remote/main').initialize(); -import { DEFAULT_WINDOW_OPTIONS } from './config'; +import { DEFAULT_APP_SETTINGS, DEFAULT_WINDOW_OPTIONS } from './config'; import { - DEFAULT_APP_SETTINGS, isMac, isWindows, isLinux, diff --git a/src/internal-server/app/Controllers/Http/UserController.js b/src/internal-server/app/Controllers/Http/UserController.js index 9bbd2ff6e..25b5277bd 100644 --- a/src/internal-server/app/Controllers/Http/UserController.js +++ b/src/internal-server/app/Controllers/Http/UserController.js @@ -7,7 +7,7 @@ const btoa = require('btoa'); const fetch = require('node-fetch'); const { v4: uuid } = require('uuid'); const crypto = require('crypto'); -const { DEFAULT_APP_SETTINGS } = require('../../../../environment'); +const { DEFAULT_APP_SETTINGS } = require('../../../../config'); const { API_VERSION } = require('../../../../environment-remote'); const { default: userAgent } = require('../../../../helpers/userAgent-helpers'); diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 83e6a899b..3d9d2b551 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -16,9 +16,8 @@ import { readJsonSync } from 'fs-extra'; import Store from './lib/Store'; import Request from './lib/Request'; -import { CHECK_INTERVAL } from '../config'; +import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; import { - DEFAULT_APP_SETTINGS, isMac, electronVersion, osRelease, diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 4b203101a..ec80fee7c 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -2,8 +2,7 @@ import { ipcRenderer } from 'electron'; import { getCurrentWindow } from '@electron/remote'; import { action, computed, observable, reaction } from 'mobx'; import localStorage from 'mobx-localstorage'; -import { FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; -import { DEFAULT_APP_SETTINGS } from '../environment'; +import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; import { hash } from '../helpers/password-helpers'; import Request from './lib/Request'; import Store from './lib/Store'; diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 892b08e54..5cab28c09 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -45,7 +45,7 @@ import { getSpellcheckerLocaleByFuzzyIdentifier, } from './spellchecker'; -import { DEFAULT_APP_SETTINGS } from '../environment'; +import { DEFAULT_APP_SETTINGS } from '../config'; const debug = require('debug')('Ferdi:Plugin'); -- cgit v1.2.3-54-g00ecf