Extract getAppVersion() util
Summary: Just some simple memoisation so we limit this particular `remote` call to one per session. Reviewed By: mweststrate Differential Revision: D26223274 fbshipit-source-id: 7a12764758823c52f68fb7075f46caf58affb22f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
40abef860f
commit
642d89213d
@@ -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() {
|
||||
<Image width={125} height={125} src="./icon.png" preview={false} />
|
||||
<Title level={1}>Welcome to Flipper</Title>
|
||||
<Text style={{color: theme.textColorPlaceholder}}>
|
||||
{isProduction() && remote
|
||||
? `Version ${remote.app.getVersion()}`
|
||||
: 'Development Mode'}
|
||||
{isProduction() ? `Version ${getAppVersion()}` : 'Development Mode'}
|
||||
</Text>
|
||||
</Space>
|
||||
<Space direction="vertical" size="large" style={{width: '100%'}}>
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -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()}`
|
||||
|
||||
Reference in New Issue
Block a user