Check for most recent Flipper version in internal builds as well

Reviewed By: passy

Differential Revision: D25945643

fbshipit-source-id: 4a831fa8d69c38004c8660597659ebd7007a3230
This commit is contained in:
Michel Weststrate
2021-01-19 07:07:33 -08:00
committed by Facebook GitHub Bot
parent 84c05d441d
commit 69c8413c57
3 changed files with 25 additions and 27 deletions

View File

@@ -16,12 +16,13 @@ import {Logger} from '../fb-interfaces/Logger';
import isSandyEnabled from '../utils/isSandyEnabled';
import {SandyApp} from '../sandy-chrome/SandyApp';
import {notification} from 'antd';
import isProduction from '../utils/isProduction';
type Props = {logger: Logger};
export default function App(props: Props) {
useEffect(() => {
if (fbConfig.warnFBEmployees) {
if (fbConfig.warnFBEmployees && isProduction()) {
isFBEmployee().then(() => {
notification.warning({
placement: 'bottomLeft',

View File

@@ -9,19 +9,29 @@
import {notification, Typography} from 'antd';
import isProduction from '../utils/isProduction';
import {
checkForUpdate,
VersionCheckResult,
} from '../utils/publicVersionChecker';
import {reportPlatformFailures} from '../utils/metrics';
import React, {useEffect, useState} from 'react';
import config from '../utils/processConfig';
import fbConfig from '../fb-stubs/config';
import {useStore} from '../utils/useStore';
import {remote} from 'electron';
import {checkForUpdate} from '../fb-stubs/checkForUpdate';
const version = remote.app.getVersion();
export type VersionCheckResult =
| {
kind: 'update-available';
url: string;
version: string;
}
| {
kind: 'up-to-date';
}
| {
kind: 'error';
msg: string;
};
export default function UpdateIndicator() {
const [versionCheckResult, setVersionCheckResult] = useState<
VersionCheckResult
@@ -93,10 +103,7 @@ export default function UpdateIndicator() {
duration: null,
});
}
} else if (
isProduction() &&
(config().launcherEnabled || !fbConfig.isFBBuild)
) {
} else if (isProduction()) {
reportPlatformFailures(
checkForUpdate(version).then((res) => {
if (res.kind === 'error') {

View File

@@ -8,7 +8,9 @@
*/
import os from 'os';
import config from '../fb-stubs/config';
import {VersionCheckResult} from '../chrome/UpdateIndicator';
const updateServer = 'https://www.facebook.com/fbflipper/public/latest.json';
const getPlatformSpecifier = (): string => {
switch (os.platform()) {
@@ -47,24 +49,10 @@ const parseResponse = (resp: any): VersionCheckResult => {
};
};
export type VersionCheckResult =
| {
kind: 'update-available';
url: string;
version: string;
}
| {
kind: 'up-to-date';
}
| {
kind: 'error';
msg: string;
};
export async function checkForUpdate(
currentVersion: string,
): Promise<VersionCheckResult> {
return fetch(`${config.updateServer}?version=${currentVersion}`).then(
return fetch(`${updateServer}?version=${currentVersion}`).then(
(res: Response) => {
switch (res.status) {
case 204:
@@ -79,9 +67,11 @@ export async function checkForUpdate(
}
return res.json().then(parseResponse);
default:
const msg = `Server responded with ${res.statusText}.`;
console.warn('Version check failure: ', msg);
return {
kind: 'error',
msg: `Server responded with ${res.statusText}.`,
msg,
};
}
},