diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/environment.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/environment.js')
-rw-r--r-- | src/environment.js | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/src/environment.js b/src/environment.js index 758a33380..42c6b2927 100644 --- a/src/environment.js +++ b/src/environment.js | |||
@@ -1,10 +1,11 @@ | |||
1 | import os from 'os'; | 1 | import os from 'os'; |
2 | import path from 'path'; | 2 | import { join } from 'path'; |
3 | 3 | ||
4 | import { is, api as electronApi } from 'electron-util'; | 4 | import { is, api as electronApi } from 'electron-util'; |
5 | 5 | ||
6 | import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; | 6 | import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; |
7 | 7 | ||
8 | import osName from 'os-name'; | ||
8 | import { | 9 | import { |
9 | LIVE_FERDI_API, | 10 | LIVE_FERDI_API, |
10 | DEV_FRANZ_API, | 11 | DEV_FRANZ_API, |
@@ -17,7 +18,6 @@ import { | |||
17 | DEV_WS_API, | 18 | DEV_WS_API, |
18 | LOCAL_TODOS_FRONTEND_URL, | 19 | LOCAL_TODOS_FRONTEND_URL, |
19 | PRODUCTION_TODOS_FRONTEND_URL, | 20 | PRODUCTION_TODOS_FRONTEND_URL, |
20 | LIVE_FRANZ_API, | ||
21 | DEFAULT_TODO_SERVICE, | 21 | DEFAULT_TODO_SERVICE, |
22 | SEARCH_ENGINE_DDG, | 22 | SEARCH_ENGINE_DDG, |
23 | iconSizeBias, | 23 | iconSizeBias, |
@@ -26,8 +26,6 @@ import { | |||
26 | import { asarPath } from './helpers/asar-helpers'; | 26 | import { asarPath } from './helpers/asar-helpers'; |
27 | import * as buildInfo from './buildInfo.json'; // eslint-disable-line import/no-unresolved | 27 | import * as buildInfo from './buildInfo.json'; // eslint-disable-line import/no-unresolved |
28 | 28 | ||
29 | const osName = require('os-name'); | ||
30 | |||
31 | export const { app } = electronApi; | 29 | export const { app } = electronApi; |
32 | export const ferdiVersion = app.getVersion(); | 30 | export const ferdiVersion = app.getVersion(); |
33 | export const electronVersion = process.versions.electron; | 31 | export const electronVersion = process.versions.electron; |
@@ -37,26 +35,35 @@ export const nodeVersion = process.versions.node; | |||
37 | // Set app directory before loading user modules | 35 | // Set app directory before loading user modules |
38 | if (process.env.FERDI_APPDATA_DIR != null) { | 36 | if (process.env.FERDI_APPDATA_DIR != null) { |
39 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | 37 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); |
40 | app.setPath('userData', path.join(app.getPath('appData'))); | 38 | app.setPath('userData', join(app.getPath('appData'))); |
41 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { | 39 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { |
42 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); | 40 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); |
43 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}AppData`)); | 41 | app.setPath('userData', join(app.getPath('appData'), `${app.name}AppData`)); |
44 | } else if (is.windows) { | 42 | } else if (is.windows) { |
45 | app.setPath('appData', process.env.APPDATA); | 43 | app.setPath('appData', process.env.APPDATA); |
46 | app.setPath('userData', path.join(app.getPath('appData'), app.name)); | 44 | app.setPath('userData', join(app.getPath('appData'), app.name)); |
47 | } | 45 | } |
48 | 46 | ||
49 | export const isDevMode = is.development; | 47 | export const isDevMode = is.development; |
50 | if (isDevMode) { | 48 | if (isDevMode) { |
51 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}Dev`)); | 49 | app.setPath('userData', join(app.getPath('appData'), `${app.name}Dev`)); |
52 | } | 50 | } |
53 | 51 | ||
54 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); | 52 | export function userDataPath(...segments) { |
53 | return join(app.getPath('userData'), ...([segments].flat())); | ||
54 | } | ||
55 | |||
56 | export function userDataRecipesPath(...segments) { | ||
57 | return userDataPath('recipes', ...([segments].flat())); | ||
58 | } | ||
55 | 59 | ||
56 | // Replacing app.asar is not beautiful but unfortunately necessary | 60 | // Replacing app.asar is not beautiful but unfortunately necessary |
57 | export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes')); | 61 | export function asarRecipesPath(...segments) { |
62 | return join(asarPath(join(__dirname, 'recipes')), ...([segments].flat())); | ||
63 | } | ||
58 | 64 | ||
59 | export const useLiveAPI = process.env.LIVE_API; | 65 | export const useLiveAPI = process.env.USE_LIVE_API; |
66 | const useLocalAPI = process.env.USE_LOCAL_API; | ||
60 | 67 | ||
61 | export const isMac = is.macos; | 68 | export const isMac = is.macos; |
62 | export const isWindows = is.windows; | 69 | export const isWindows = is.windows; |
@@ -66,8 +73,22 @@ export const osArch = os.arch(); | |||
66 | export const osRelease = os.release(); | 73 | export const osRelease = os.release(); |
67 | export const is64Bit = osArch.match(/64/); | 74 | export const is64Bit = osArch.match(/64/); |
68 | 75 | ||
69 | export const ctrlKey = isMac ? '⌘' : 'Ctrl'; | 76 | // for accelerator, show the shortform that electron/OS understands |
70 | export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; | 77 | // for tooltip, show symbol |
78 | const ctrlKey = isMac ? '⌘' : 'Ctrl'; | ||
79 | const cmdKey = isMac ? 'Cmd' : 'Ctrl'; | ||
80 | |||
81 | export const altKey = isMac ? '⌥' : 'Alt'; | ||
82 | export const shiftKey = isMac ? '⇧' : 'Shift'; | ||
83 | |||
84 | // Platform specific shortcut keys | ||
85 | export const shortcutKey = (isAccelerator = true) => (isAccelerator ? cmdKey : ctrlKey); | ||
86 | export const lockFerdiShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+${shiftKey}+L`; | ||
87 | export const todosToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+T`; | ||
88 | export const workspaceToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+D`; | ||
89 | export const muteFerdiShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+${shiftKey}+M`; | ||
90 | export const addNewServiceShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+N`; | ||
91 | export const settingsShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+${isMac ? ',' : 'P'}`; | ||
71 | 92 | ||
72 | let api; | 93 | let api; |
73 | let wsApi; | 94 | let wsApi; |
@@ -75,12 +96,10 @@ let web; | |||
75 | let todos; | 96 | let todos; |
76 | if (!isDevMode || (isDevMode && useLiveAPI)) { | 97 | if (!isDevMode || (isDevMode && useLiveAPI)) { |
77 | api = LIVE_FERDI_API; | 98 | api = LIVE_FERDI_API; |
78 | // api = DEV_FRANZ_API; | ||
79 | wsApi = LIVE_WS_API; | 99 | wsApi = LIVE_WS_API; |
80 | web = LIVE_API_FERDI_WEBSITE; | 100 | web = LIVE_API_FERDI_WEBSITE; |
81 | // web = DEV_API_FRANZ_WEBSITE; | ||
82 | todos = PRODUCTION_TODOS_FRONTEND_URL; | 101 | todos = PRODUCTION_TODOS_FRONTEND_URL; |
83 | } else if (isDevMode && process.env.LOCAL_API) { | 102 | } else if (isDevMode && useLocalAPI) { |
84 | api = LOCAL_API; | 103 | api = LOCAL_API; |
85 | wsApi = LOCAL_WS_API; | 104 | wsApi = LOCAL_WS_API; |
86 | web = LOCAL_API_WEBSITE; | 105 | web = LOCAL_API_WEBSITE; |
@@ -120,7 +139,6 @@ export const DEFAULT_APP_SETTINGS = { | |||
120 | beta: false, | 139 | beta: false, |
121 | isAppMuted: false, | 140 | isAppMuted: false, |
122 | enableGPUAcceleration: true, | 141 | enableGPUAcceleration: true, |
123 | serviceLimit: 5, | ||
124 | 142 | ||
125 | // Ferdi specific options | 143 | // Ferdi specific options |
126 | server: LIVE_FERDI_API, | 144 | server: LIVE_FERDI_API, |
@@ -133,9 +151,9 @@ export const DEFAULT_APP_SETTINGS = { | |||
133 | scheduledDNDEnabled: false, | 151 | scheduledDNDEnabled: false, |
134 | scheduledDNDStart: '17:00', | 152 | scheduledDNDStart: '17:00', |
135 | scheduledDNDEnd: '09:00', | 153 | scheduledDNDEnd: '09:00', |
136 | hibernate: false, | ||
137 | hibernateOnStartup: true, | 154 | hibernateOnStartup: true, |
138 | hibernationStrategy: 300, | 155 | hibernationStrategy: '300', // seconds |
156 | wakeUpStrategy: '300', // seconds | ||
139 | inactivityLock: 0, | 157 | inactivityLock: 0, |
140 | automaticUpdates: true, | 158 | automaticUpdates: true, |
141 | showServiceNavigationBar: false, | 159 | showServiceNavigationBar: false, |
@@ -153,10 +171,6 @@ export const DEFAULT_APP_SETTINGS = { | |||
153 | alwaysShowWorkspaces: false, | 171 | alwaysShowWorkspaces: false, |
154 | }; | 172 | }; |
155 | 173 | ||
156 | export function termsBase() { | ||
157 | return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE; | ||
158 | } | ||
159 | |||
160 | export function aboutAppDetails() { | 174 | export function aboutAppDetails() { |
161 | return [ | 175 | return [ |
162 | `Version: ${ferdiVersion}`, | 176 | `Version: ${ferdiVersion}`, |