diff --git a/desktop/app/src/sandy-chrome/WelcomeScreen.tsx b/desktop/app/src/sandy-chrome/WelcomeScreen.tsx index 276847de0..5d52980a0 100644 --- a/desktop/app/src/sandy-chrome/WelcomeScreen.tsx +++ b/desktop/app/src/sandy-chrome/WelcomeScreen.tsx @@ -22,7 +22,8 @@ const {Text, Title} = Typography; import constants from '../fb-stubs/constants'; import isProduction from '../utils/isProduction'; -import {shell, remote} from 'electron'; +import {getAppVersion} from '../utils/info'; +import {shell} from 'electron'; const RowContainer = styled(FlexRow)({ alignItems: 'flex-start', @@ -144,9 +145,7 @@ function WelcomeScreenContent() { Welcome to Flipper - {isProduction() && remote - ? `Version ${remote.app.getVersion()}` - : 'Development Mode'} + {isProduction() ? `Version ${getAppVersion()}` : 'Development Mode'} diff --git a/desktop/app/src/utils/exportData.tsx b/desktop/app/src/utils/exportData.tsx index e4d94a447..f209ebf37 100644 --- a/desktop/app/src/utils/exportData.tsx +++ b/desktop/app/src/utils/exportData.tsx @@ -17,6 +17,7 @@ import {State as PluginStatesState} from '../reducers/pluginStates'; import {State as PluginsState} from '../reducers/plugins'; import {PluginNotification} from '../reducers/notifications'; import Client, {ClientExport, ClientQuery} from '../Client'; +import {getAppVersion} from './info'; import {pluginKey} from '../reducers/pluginStates'; import { callClient, @@ -383,7 +384,7 @@ async function addSaltToDeviceSerial({ }); const revision: string | undefined = await readCurrentRevision(); return { - fileVersion: remote.app.getVersion(), + fileVersion: getAppVersion() || 'unknown', flipperReleaseRevision: revision, clients: updatedClients, device: {...newDevice.toJSON(), pluginStates: devicePluginStates}, diff --git a/desktop/app/src/utils/info.tsx b/desktop/app/src/utils/info.tsx index 053a5e047..fec79c43c 100644 --- a/desktop/app/src/utils/info.tsx +++ b/desktop/app/src/utils/info.tsx @@ -8,6 +8,7 @@ */ import os from 'os'; +import {remote} from 'electron'; export type Info = { arch: string; @@ -35,6 +36,17 @@ export function getInfo(): Info { }; } +let APP_VERSION: string | undefined = undefined; +// Prefer using this function over manually calling `remote.app.getVersion()` +// as calls to the remote object go over IPC and can be slow. +export function getAppVersion(): string | undefined { + if (APP_VERSION === undefined && remote) { + APP_VERSION = remote.app.getVersion(); + } + + return APP_VERSION; +} + export function stringifyInfo(info: Info): string { const lines = [ `Platform: ${info.platform} ${info.arch}`, diff --git a/desktop/app/src/utils/versionString.tsx b/desktop/app/src/utils/versionString.tsx index 5590bb077..3c88ff0bf 100644 --- a/desktop/app/src/utils/versionString.tsx +++ b/desktop/app/src/utils/versionString.tsx @@ -8,15 +8,13 @@ */ import isProduction from '../utils/isProduction'; -import {remote} from 'electron'; +import {getAppVersion} from './info'; import config from '../fb-stubs/config'; import ReleaseChannel from '../ReleaseChannel'; -const version = remote.app.getVersion(); - export function getVersionString() { return ( - version + + getAppVersion() + (isProduction() ? '' : '-dev') + (config.getReleaseChannel() !== ReleaseChannel.STABLE ? `-${config.getReleaseChannel()}`