From 08e742ceff138be9d69e5680099e606f55d9158c Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 1 Nov 2023 11:15:17 -0700 Subject: [PATCH] Utility to determine if client is PWA Summary: This is currently used in multiple places, let's put it under utils. Reviewed By: aigoncharov Differential Revision: D50883125 fbshipit-source-id: ee161a035cd01ca73a2521f813c4b397aa647037 --- desktop/flipper-ui-core/src/index.tsx | 2 ++ desktop/flipper-ui-core/src/utils/pwa.tsx | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 desktop/flipper-ui-core/src/utils/pwa.tsx diff --git a/desktop/flipper-ui-core/src/index.tsx b/desktop/flipper-ui-core/src/index.tsx index 83369ac66..9fcd909c3 100644 --- a/desktop/flipper-ui-core/src/index.tsx +++ b/desktop/flipper-ui-core/src/index.tsx @@ -12,3 +12,5 @@ export {RenderHost, getRenderHostInstance} from 'flipper-frontend-core'; export {startFlipperDesktop} from './startFlipperDesktop'; export {Icon} from './utils/icons'; + +export {isPWA} from './utils/pwa'; diff --git a/desktop/flipper-ui-core/src/utils/pwa.tsx b/desktop/flipper-ui-core/src/utils/pwa.tsx new file mode 100644 index 000000000..3a0142db7 --- /dev/null +++ b/desktop/flipper-ui-core/src/utils/pwa.tsx @@ -0,0 +1,12 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +export const isPWA = () => { + return window.matchMedia('(display-mode: standalone)').matches; +};