aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-07-15 23:10:08 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-07-15 23:10:08 +0530
commitc3711a2b577a10584bac0fbddfb7bde108eb706c (patch)
treeafd2210823b6e7dbbc250186c21496c19aff1217
parentRevert 'useragent-generator' to published npm version without github repo ref... (diff)
downloadferdium-app-c3711a2b577a10584bac0fbddfb7bde108eb706c.tar.gz
ferdium-app-c3711a2b577a10584bac0fbddfb7bde108eb706c.tar.zst
ferdium-app-c3711a2b577a10584bac0fbddfb7bde108eb706c.zip
Minor perf tweaks to evaluate capturing of env-specific values only once in the application.
-rw-r--r--src/api/server/ServerApi.js5
-rw-r--r--src/environment.js5
-rw-r--r--src/helpers/userAgent-helpers.js16
-rw-r--r--src/i18n/locales/defaultMessages.json28
-rw-r--r--src/lib/TouchBar.js5
-rw-r--r--src/stores/AppStore.js5
6 files changed, 32 insertions, 32 deletions
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js
index 24d095556..c63aa7dda 100644
--- a/src/api/server/ServerApi.js
+++ b/src/api/server/ServerApi.js
@@ -1,4 +1,3 @@
1import os from 'os';
2import path from 'path'; 1import path from 'path';
3import tar from 'tar'; 2import tar from 'tar';
4import fs from 'fs-extra'; 3import fs from 'fs-extra';
@@ -15,7 +14,7 @@ import OrderModel from '../../models/Order';
15import { sleep } from '../../helpers/async-helpers'; 14import { sleep } from '../../helpers/async-helpers';
16 15
17import { SERVER_NOT_LOADED } from '../../config'; 16import { SERVER_NOT_LOADED } from '../../config';
18import { RECIPES_PATH } from '../../environment'; 17import { osArch, osPlatform, RECIPES_PATH } from '../../environment';
19import apiBase from '../apiBase'; 18import apiBase from '../apiBase';
20import { prepareAuthRequest, sendAuthRequest } from '../utils/auth'; 19import { prepareAuthRequest, sendAuthRequest } from '../utils/auth';
21 20
@@ -456,7 +455,7 @@ export default class ServerApi {
456 455
457 // News 456 // News
458 async getLatestNews() { 457 async getLatestNews() {
459 const url = `${apiBase(true)}/news?platform=${os.platform()}&arch=${os.arch()}&version=${app.getVersion()}`; 458 const url = `${apiBase(true)}/news?platform=${osPlatform}&arch=${osArch}&version=${app.getVersion()}`;
460 const request = await sendAuthRequest(url); 459 const request = await sendAuthRequest(url);
461 if (!request.ok) throw request; 460 if (!request.ok) throw request;
462 const data = await request.json(); 461 const data = await request.json();
diff --git a/src/environment.js b/src/environment.js
index be6dc7176..758a33380 100644
--- a/src/environment.js
+++ b/src/environment.js
@@ -1,3 +1,4 @@
1import os from 'os';
1import path from 'path'; 2import path from 'path';
2 3
3import { is, api as electronApi } from 'electron-util'; 4import { is, api as electronApi } from 'electron-util';
@@ -60,6 +61,10 @@ export const useLiveAPI = process.env.LIVE_API;
60export const isMac = is.macos; 61export const isMac = is.macos;
61export const isWindows = is.windows; 62export const isWindows = is.windows;
62export const isLinux = is.linux; 63export const isLinux = is.linux;
64export const osPlatform = os.platform();
65export const osArch = os.arch();
66export const osRelease = os.release();
67export const is64Bit = osArch.match(/64/);
63 68
64export const ctrlKey = isMac ? '⌘' : 'Ctrl'; 69export const ctrlKey = isMac ? '⌘' : 'Ctrl';
65export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; 70export const cmdKey = isMac ? 'Cmd' : 'Ctrl';
diff --git a/src/helpers/userAgent-helpers.js b/src/helpers/userAgent-helpers.js
index 4aa6f92d0..9c9c8f132 100644
--- a/src/helpers/userAgent-helpers.js
+++ b/src/helpers/userAgent-helpers.js
@@ -1,13 +1,11 @@
1import os from 'os'; 1import os from 'os';
2import macosVersion from 'macos-version'; 2import macosVersion from 'macos-version';
3import { chromeVersion, isMac, isWindows } from '../environment'; 3import {
4 chromeVersion, isMac, isWindows, is64Bit, osArch, osRelease,
5} from '../environment';
4 6
5const uaGenerator = require('useragent-generator'); 7const uaGenerator = require('useragent-generator');
6 8
7function is64Bit() {
8 return os.arch().match(/64/);
9}
10
11function macOS() { 9function macOS() {
12 const version = macosVersion(); 10 const version = macosVersion();
13 let cpuName = os.cpus()[0].model.split(' ')[0]; 11 let cpuName = os.cpus()[0].model.split(' ')[0];
@@ -18,14 +16,14 @@ function macOS() {
18} 16}
19 17
20function windows() { 18function windows() {
21 const version = os.release(); 19 const version = osRelease;
22 const [majorVersion, minorVersion] = version.split('.'); 20 const [majorVersion, minorVersion] = version.split('.');
23 const archString = is64Bit() ? 'Win64' : 'Win32'; 21 const archString = is64Bit ? 'Win64' : 'Win32';
24 return `Windows NT ${majorVersion}.${minorVersion}; ${archString}; ${os.arch()}`; 22 return `Windows NT ${majorVersion}.${minorVersion}; ${archString}; ${osArch}`;
25} 23}
26 24
27function linux() { 25function linux() {
28 const archString = is64Bit() ? 'x86_64' : os.arch(); 26 const archString = is64Bit ? 'x86_64' : osArch;
29 return `X11; Ubuntu; Linux ${archString}`; 27 return `X11; Ubuntu; Linux ${archString}`;
30} 28}
31 29
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json
index 4da9390a5..370a6fb92 100644
--- a/src/i18n/locales/defaultMessages.json
+++ b/src/i18n/locales/defaultMessages.json
@@ -6142,91 +6142,91 @@
6142 "defaultMessage": "!!!Publish debug information", 6142 "defaultMessage": "!!!Publish debug information",
6143 "end": { 6143 "end": {
6144 "column": 3, 6144 "column": 3,
6145 "line": 20 6145 "line": 22
6146 }, 6146 },
6147 "file": "src/features/publishDebugInfo/Component.js", 6147 "file": "src/features/publishDebugInfo/Component.js",
6148 "id": "feature.publishDebugInfo.title", 6148 "id": "feature.publishDebugInfo.title",
6149 "start": { 6149 "start": {
6150 "column": 9, 6150 "column": 9,
6151 "line": 17 6151 "line": 19
6152 } 6152 }
6153 }, 6153 },
6154 { 6154 {
6155 "defaultMessage": "!!!Publishing your debug information helps us find issues and errors in Ferdi. By publishing your debug information you accept Ferdi Debugger's privacy policy and terms of service", 6155 "defaultMessage": "!!!Publishing your debug information helps us find issues and errors in Ferdi. By publishing your debug information you accept Ferdi Debugger's privacy policy and terms of service",
6156 "end": { 6156 "end": {
6157 "column": 3, 6157 "column": 3,
6158 "line": 24 6158 "line": 26
6159 }, 6159 },
6160 "file": "src/features/publishDebugInfo/Component.js", 6160 "file": "src/features/publishDebugInfo/Component.js",
6161 "id": "feature.publishDebugInfo.info", 6161 "id": "feature.publishDebugInfo.info",
6162 "start": { 6162 "start": {
6163 "column": 8, 6163 "column": 8,
6164 "line": 21 6164 "line": 23
6165 } 6165 }
6166 }, 6166 },
6167 { 6167 {
6168 "defaultMessage": "!!!There was an error while trying to publish the debug information. Please try again later or view the console for more information.", 6168 "defaultMessage": "!!!There was an error while trying to publish the debug information. Please try again later or view the console for more information.",
6169 "end": { 6169 "end": {
6170 "column": 3, 6170 "column": 3,
6171 "line": 28 6171 "line": 30
6172 }, 6172 },
6173 "file": "src/features/publishDebugInfo/Component.js", 6173 "file": "src/features/publishDebugInfo/Component.js",
6174 "id": "feature.publishDebugInfo.error", 6174 "id": "feature.publishDebugInfo.error",
6175 "start": { 6175 "start": {
6176 "column": 9, 6176 "column": 9,
6177 "line": 25 6177 "line": 27
6178 } 6178 }
6179 }, 6179 },
6180 { 6180 {
6181 "defaultMessage": "!!!Privacy policy", 6181 "defaultMessage": "!!!Privacy policy",
6182 "end": { 6182 "end": {
6183 "column": 3, 6183 "column": 3,
6184 "line": 32 6184 "line": 34
6185 }, 6185 },
6186 "file": "src/features/publishDebugInfo/Component.js", 6186 "file": "src/features/publishDebugInfo/Component.js",
6187 "id": "feature.publishDebugInfo.privacy", 6187 "id": "feature.publishDebugInfo.privacy",
6188 "start": { 6188 "start": {
6189 "column": 11, 6189 "column": 11,
6190 "line": 29 6190 "line": 31
6191 } 6191 }
6192 }, 6192 },
6193 { 6193 {
6194 "defaultMessage": "!!!Terms of service", 6194 "defaultMessage": "!!!Terms of service",
6195 "end": { 6195 "end": {
6196 "column": 3, 6196 "column": 3,
6197 "line": 36 6197 "line": 38
6198 }, 6198 },
6199 "file": "src/features/publishDebugInfo/Component.js", 6199 "file": "src/features/publishDebugInfo/Component.js",
6200 "id": "feature.publishDebugInfo.terms", 6200 "id": "feature.publishDebugInfo.terms",
6201 "start": { 6201 "start": {
6202 "column": 9, 6202 "column": 9,
6203 "line": 33 6203 "line": 35
6204 } 6204 }
6205 }, 6205 },
6206 { 6206 {
6207 "defaultMessage": "!!!Accept and publish", 6207 "defaultMessage": "!!!Accept and publish",
6208 "end": { 6208 "end": {
6209 "column": 3, 6209 "column": 3,
6210 "line": 40 6210 "line": 42
6211 }, 6211 },
6212 "file": "src/features/publishDebugInfo/Component.js", 6212 "file": "src/features/publishDebugInfo/Component.js",
6213 "id": "feature.publishDebugInfo.publish", 6213 "id": "feature.publishDebugInfo.publish",
6214 "start": { 6214 "start": {
6215 "column": 11, 6215 "column": 11,
6216 "line": 37 6216 "line": 39
6217 } 6217 }
6218 }, 6218 },
6219 { 6219 {
6220 "defaultMessage": "!!!Your debug log was published and is now availible at", 6220 "defaultMessage": "!!!Your debug log was published and is now availible at",
6221 "end": { 6221 "end": {
6222 "column": 3, 6222 "column": 3,
6223 "line": 44 6223 "line": 46
6224 }, 6224 },
6225 "file": "src/features/publishDebugInfo/Component.js", 6225 "file": "src/features/publishDebugInfo/Component.js",
6226 "id": "feature.publishDebugInfo.published", 6226 "id": "feature.publishDebugInfo.published",
6227 "start": { 6227 "start": {
6228 "column": 13, 6228 "column": 13,
6229 "line": 41 6229 "line": 43
6230 } 6230 }
6231 } 6231 }
6232 ], 6232 ],
diff --git a/src/lib/TouchBar.js b/src/lib/TouchBar.js
index 11eaec306..781cd0895 100644
--- a/src/lib/TouchBar.js
+++ b/src/lib/TouchBar.js
@@ -1,9 +1,8 @@
1import os from 'os';
2import semver from 'semver'; 1import semver from 'semver';
3import { TouchBar, getCurrentWindow } from '@electron/remote'; 2import { TouchBar, getCurrentWindow } from '@electron/remote';
4import { autorun } from 'mobx'; 3import { autorun } from 'mobx';
5 4
6import { isMac } from '../environment'; 5import { isMac, osRelease } from '../environment';
7 6
8export default class FranzTouchBar { 7export default class FranzTouchBar {
9 constructor(stores, actions) { 8 constructor(stores, actions) {
@@ -13,7 +12,7 @@ export default class FranzTouchBar {
13 // Temporary fix for https://github.com/electron/electron/issues/10442 12 // Temporary fix for https://github.com/electron/electron/issues/10442
14 // TODO: remove when we upgrade to electron 1.8.2 or later 13 // TODO: remove when we upgrade to electron 1.8.2 or later
15 try { 14 try {
16 if (isMac && semver.gt(os.release(), '16.6.0')) { 15 if (isMac && semver.gt(osRelease, '16.6.0')) {
17 this.build = autorun(this._build.bind(this)); 16 this.build = autorun(this._build.bind(this));
18 } 17 }
19 } catch (err) { 18 } catch (err) {
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index bbcf78a43..ac6ca6d2d 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -7,7 +7,6 @@ import moment from 'moment';
7import AutoLaunch from 'auto-launch'; 7import AutoLaunch from 'auto-launch';
8import ms from 'ms'; 8import ms from 'ms';
9import { URL } from 'url'; 9import { URL } from 'url';
10import os from 'os';
11import path from 'path'; 10import path from 'path';
12import { readJsonSync } from 'fs-extra'; 11import { readJsonSync } from 'fs-extra';
13 12
@@ -15,7 +14,7 @@ import Store from './lib/Store';
15import Request from './lib/Request'; 14import Request from './lib/Request';
16import { CHECK_INTERVAL } from '../config'; 15import { CHECK_INTERVAL } from '../config';
17import { 16import {
18 DEFAULT_APP_SETTINGS, isMac, ferdiVersion, electronVersion, 17 DEFAULT_APP_SETTINGS, isMac, ferdiVersion, electronVersion, osRelease,
19} from '../environment'; 18} from '../environment';
20import locales from '../i18n/translations'; 19import locales from '../i18n/translations';
21import { onVisibilityChange } from '../helpers/visibility-helper'; 20import { onVisibilityChange } from '../helpers/visibility-helper';
@@ -261,7 +260,7 @@ export default class AppStore extends Store {
261 return { 260 return {
262 host: { 261 host: {
263 platform: process.platform, 262 platform: process.platform,
264 release: os.release(), 263 release: osRelease,
265 screens: screen.getAllDisplays(), 264 screens: screen.getAllDisplays(),
266 }, 265 },
267 ferdi: { 266 ferdi: {