From 1a9803897969bcbcb316bde9448cd611eff491e4 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 1 Nov 2023 11:15:17 -0700 Subject: [PATCH] Use isPWA utility function instead Summary: As a follow-up from the utility created on the previous diff Reviewed By: aigoncharov Differential Revision: D50885337 fbshipit-source-id: 6bc0c942b3d96eb020ec15395f34d5794ba2ae15 --- desktop/flipper-ui-browser/src/index.tsx | 3 ++- desktop/flipper-ui-core/src/chrome/PWAppInstallationWizard.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index f7fcc645e..23efa6733 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -15,6 +15,7 @@ import { import {init as initLogger} from './fb-stubs/Logger'; import {initializeRenderHost} from './initializeRenderHost'; import {createFlipperServer, FlipperServerState} from 'flipper-server-client'; +import {isPWA} from 'flipper-ui-core'; const loadingContainer = document.getElementById('loading'); if (loadingContainer) { @@ -151,7 +152,7 @@ start().catch((e) => { logger.track('success-rate', 'flipper-ui-browser-started', { value: 0, error: getStringFromErrorLike(e), - pwa: window.matchMedia('(display-mode: standalone)').matches, + pwa: isPWA(), }); window.flipperShowMessage?.('Failed to start UI with error: ' + e); }); diff --git a/desktop/flipper-ui-core/src/chrome/PWAppInstallationWizard.tsx b/desktop/flipper-ui-core/src/chrome/PWAppInstallationWizard.tsx index 84ce4f5d2..9e3f648d6 100644 --- a/desktop/flipper-ui-core/src/chrome/PWAppInstallationWizard.tsx +++ b/desktop/flipper-ui-core/src/chrome/PWAppInstallationWizard.tsx @@ -12,6 +12,7 @@ import {Image, Modal, Button} from 'antd'; import {getFlipperLib, Layout, _NuxManagerContext} from 'flipper-plugin'; import {getRenderHostInstance} from 'flipper-frontend-core'; import isProduction from '../utils/isProduction'; +import {isPWA} from '../utils/pwa'; type Props = { onHide: () => void; @@ -55,7 +56,7 @@ export function shouldShowPWAInstallationWizard(): boolean { return false; } - if (window.matchMedia('(display-mode: standalone)').matches) { + if (isPWA()) { tracker.track('pwa-installation-wizard-should-show', { show: false, reason: 'Display mode is standalone, seems is already running as PWA',