Loading state for emulator launcher
Summary: Our current loading state holder for the emulator launch dialogue is a "No emulators available" error message which may stay there for up to 5 seconds (in the case of only iOS enabled) before we see devices. This adds a proper spinner that will show for as long there are pending device queries. Changelog: Loading state for emulator launch dialogue Reviewed By: nikoant Differential Revision: D36598855 fbshipit-source-id: 64099596b48708b48a43f0208696a7dddc15007c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fe29183014
commit
f84f56614d
@@ -17,7 +17,12 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {Store} from '../../reducers';
|
import {Store} from '../../reducers';
|
||||||
import {useStore} from '../../utils/useStore';
|
import {useStore} from '../../utils/useStore';
|
||||||
import {Layout, renderReactRoot, withTrackingScope} from 'flipper-plugin';
|
import {
|
||||||
|
Layout,
|
||||||
|
Spinner,
|
||||||
|
renderReactRoot,
|
||||||
|
withTrackingScope,
|
||||||
|
} from 'flipper-plugin';
|
||||||
import {Provider} from 'react-redux';
|
import {Provider} from 'react-redux';
|
||||||
import {IOSDeviceParams} from 'flipper-common';
|
import {IOSDeviceParams} from 'flipper-common';
|
||||||
import {getRenderHostInstance} from '../../RenderHost';
|
import {getRenderHostInstance} from '../../RenderHost';
|
||||||
@@ -80,6 +85,9 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
|
|
||||||
const [iosEmulators, setIosEmulators] = useState<IOSDeviceParams[]>([]);
|
const [iosEmulators, setIosEmulators] = useState<IOSDeviceParams[]>([]);
|
||||||
const [androidEmulators, setAndroidEmulators] = useState<string[]>([]);
|
const [androidEmulators, setAndroidEmulators] = useState<string[]>([]);
|
||||||
|
const [waitingForIos, setWaitingForIos] = useState(iosEnabled);
|
||||||
|
const [waitingForAndroid, setWaitingForAndroid] = useState(androidEnabled);
|
||||||
|
const waitingForResults = waitingForIos || waitingForAndroid;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!iosEnabled) {
|
if (!iosEnabled) {
|
||||||
@@ -88,6 +96,7 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
getRenderHostInstance()
|
getRenderHostInstance()
|
||||||
.flipperServer.exec('ios-get-simulators', false)
|
.flipperServer.exec('ios-get-simulators', false)
|
||||||
.then((emulators) => {
|
.then((emulators) => {
|
||||||
|
setWaitingForIos(false);
|
||||||
setIosEmulators(
|
setIosEmulators(
|
||||||
emulators.filter(
|
emulators.filter(
|
||||||
(device) =>
|
(device) =>
|
||||||
@@ -108,6 +117,7 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
getRenderHostInstance()
|
getRenderHostInstance()
|
||||||
.flipperServer.exec('android-get-emulators')
|
.flipperServer.exec('android-get-emulators')
|
||||||
.then((emulators) => {
|
.then((emulators) => {
|
||||||
|
setWaitingForAndroid(false);
|
||||||
setAndroidEmulators(emulators);
|
setAndroidEmulators(emulators);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -176,6 +186,15 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const loadingSpinner = (
|
||||||
|
<>
|
||||||
|
{waitingForResults && <Spinner />}
|
||||||
|
{!waitingForResults && items.length === 0 && (
|
||||||
|
<Alert message="No emulators available" />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible
|
visible
|
||||||
@@ -185,7 +204,8 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
footer={null}
|
footer={null}
|
||||||
bodyStyle={{maxHeight: 400, height: 400, overflow: 'auto'}}>
|
bodyStyle={{maxHeight: 400, height: 400, overflow: 'auto'}}>
|
||||||
<Layout.Container gap>
|
<Layout.Container gap>
|
||||||
{items.length ? items : <Alert message="No emulators available" />}
|
{items.length ? items : <></>}
|
||||||
|
{loadingSpinner}
|
||||||
</Layout.Container>
|
</Layout.Container>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user