From 69c8413c579b6ba6c0c46696cae7418a11d7c595 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 19 Jan 2021 07:07:33 -0800 Subject: [PATCH] Check for most recent Flipper version in internal builds as well Reviewed By: passy Differential Revision: D25945643 fbshipit-source-id: 4a831fa8d69c38004c8660597659ebd7007a3230 --- desktop/app/src/chrome/AppWrapper.tsx | 3 ++- desktop/app/src/chrome/UpdateIndicator.tsx | 25 ++++++++++++------- .../checkForUpdate.tsx} | 24 ++++++------------ 3 files changed, 25 insertions(+), 27 deletions(-) rename desktop/app/src/{utils/publicVersionChecker.tsx => fb-stubs/checkForUpdate.tsx} (82%) diff --git a/desktop/app/src/chrome/AppWrapper.tsx b/desktop/app/src/chrome/AppWrapper.tsx index aff7aae53..09053c39d 100644 --- a/desktop/app/src/chrome/AppWrapper.tsx +++ b/desktop/app/src/chrome/AppWrapper.tsx @@ -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', diff --git a/desktop/app/src/chrome/UpdateIndicator.tsx b/desktop/app/src/chrome/UpdateIndicator.tsx index cc49cf16d..c48a8b8c7 100644 --- a/desktop/app/src/chrome/UpdateIndicator.tsx +++ b/desktop/app/src/chrome/UpdateIndicator.tsx @@ -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') { diff --git a/desktop/app/src/utils/publicVersionChecker.tsx b/desktop/app/src/fb-stubs/checkForUpdate.tsx similarity index 82% rename from desktop/app/src/utils/publicVersionChecker.tsx rename to desktop/app/src/fb-stubs/checkForUpdate.tsx index e84fbd495..b62f25f1c 100644 --- a/desktop/app/src/utils/publicVersionChecker.tsx +++ b/desktop/app/src/fb-stubs/checkForUpdate.tsx @@ -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 { - 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, }; } },