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 constants from '../fb-stubs/constants';
|
||||||
import isProduction from '../utils/isProduction';
|
import isProduction from '../utils/isProduction';
|
||||||
import {shell, remote} from 'electron';
|
import {getAppVersion} from '../utils/info';
|
||||||
|
import {shell} from 'electron';
|
||||||
|
|
||||||
const RowContainer = styled(FlexRow)({
|
const RowContainer = styled(FlexRow)({
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
@@ -144,9 +145,7 @@ function WelcomeScreenContent() {
|
|||||||
<Image width={125} height={125} src="./icon.png" preview={false} />
|
<Image width={125} height={125} src="./icon.png" preview={false} />
|
||||||
<Title level={1}>Welcome to Flipper</Title>
|
<Title level={1}>Welcome to Flipper</Title>
|
||||||
<Text style={{color: theme.textColorPlaceholder}}>
|
<Text style={{color: theme.textColorPlaceholder}}>
|
||||||
{isProduction() && remote
|
{isProduction() ? `Version ${getAppVersion()}` : 'Development Mode'}
|
||||||
? `Version ${remote.app.getVersion()}`
|
|
||||||
: 'Development Mode'}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
<Space direction="vertical" size="large" style={{width: '100%'}}>
|
<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 {State as PluginsState} from '../reducers/plugins';
|
||||||
import {PluginNotification} from '../reducers/notifications';
|
import {PluginNotification} from '../reducers/notifications';
|
||||||
import Client, {ClientExport, ClientQuery} from '../Client';
|
import Client, {ClientExport, ClientQuery} from '../Client';
|
||||||
|
import {getAppVersion} from './info';
|
||||||
import {pluginKey} from '../reducers/pluginStates';
|
import {pluginKey} from '../reducers/pluginStates';
|
||||||
import {
|
import {
|
||||||
callClient,
|
callClient,
|
||||||
@@ -383,7 +384,7 @@ async function addSaltToDeviceSerial({
|
|||||||
});
|
});
|
||||||
const revision: string | undefined = await readCurrentRevision();
|
const revision: string | undefined = await readCurrentRevision();
|
||||||
return {
|
return {
|
||||||
fileVersion: remote.app.getVersion(),
|
fileVersion: getAppVersion() || 'unknown',
|
||||||
flipperReleaseRevision: revision,
|
flipperReleaseRevision: revision,
|
||||||
clients: updatedClients,
|
clients: updatedClients,
|
||||||
device: {...newDevice.toJSON(), pluginStates: devicePluginStates},
|
device: {...newDevice.toJSON(), pluginStates: devicePluginStates},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import {remote} from 'electron';
|
||||||
|
|
||||||
export type Info = {
|
export type Info = {
|
||||||
arch: string;
|
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 {
|
export function stringifyInfo(info: Info): string {
|
||||||
const lines = [
|
const lines = [
|
||||||
`Platform: ${info.platform} ${info.arch}`,
|
`Platform: ${info.platform} ${info.arch}`,
|
||||||
|
|||||||
@@ -8,15 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import isProduction from '../utils/isProduction';
|
import isProduction from '../utils/isProduction';
|
||||||
import {remote} from 'electron';
|
import {getAppVersion} from './info';
|
||||||
import config from '../fb-stubs/config';
|
import config from '../fb-stubs/config';
|
||||||
import ReleaseChannel from '../ReleaseChannel';
|
import ReleaseChannel from '../ReleaseChannel';
|
||||||
|
|
||||||
const version = remote.app.getVersion();
|
|
||||||
|
|
||||||
export function getVersionString() {
|
export function getVersionString() {
|
||||||
return (
|
return (
|
||||||
version +
|
getAppVersion() +
|
||||||
(isProduction() ? '' : '-dev') +
|
(isProduction() ? '' : '-dev') +
|
||||||
(config.getReleaseChannel() !== ReleaseChannel.STABLE
|
(config.getReleaseChannel() !== ReleaseChannel.STABLE
|
||||||
? `-${config.getReleaseChannel()}`
|
? `-${config.getReleaseChannel()}`
|
||||||
|
|||||||
Reference in New Issue
Block a user