Use spinner when loading Flipper trace
Summary: When loading a Flipper trace, the loading dialog was no longer show. This diff fixes that. Reviewed By: nikoant Differential Revision: D29844892 fbshipit-source-id: 23d1f53962a3f64f93cc42127cd008c03486c14c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
62674da74e
commit
ba6ab0ff38
@@ -11,7 +11,6 @@ import {
|
||||
ACTIVE_SHEET_SIGN_IN,
|
||||
setActiveSheet,
|
||||
setPastedToken,
|
||||
toggleAction,
|
||||
} from './reducers/application';
|
||||
import {Group, SUPPORTED_GROUPS} from './reducers/supportForm';
|
||||
import {Store} from './reducers/index';
|
||||
@@ -19,6 +18,7 @@ import {importDataToStore} from './utils/exportData';
|
||||
import {selectPlugin} from './reducers/connections';
|
||||
import {Dialog} from 'flipper-plugin';
|
||||
import {handleOpenPluginDeeplink} from './dispatcher/handleOpenPluginDeeplink';
|
||||
import {message} from 'antd';
|
||||
|
||||
const UNKNOWN = 'Unknown deeplink';
|
||||
/**
|
||||
@@ -37,18 +37,22 @@ export async function handleDeeplink(
|
||||
}
|
||||
if (uri.pathname.match(/^\/*import\/*$/)) {
|
||||
const url = uri.searchParams.get('url');
|
||||
store.dispatch(toggleAction('downloadingImportData', true));
|
||||
if (url) {
|
||||
const handle = Dialog.loading({
|
||||
message: 'Importing Flipper trace...',
|
||||
});
|
||||
return fetch(url)
|
||||
.then((res) => res.text())
|
||||
.then((data) => importDataToStore(url, data, store))
|
||||
.then(() => {
|
||||
store.dispatch(toggleAction('downloadingImportData', false));
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
console.error('Failed to download Flipper trace' + e);
|
||||
store.dispatch(toggleAction('downloadingImportData', false));
|
||||
throw e;
|
||||
console.warn('Failed to download Flipper trace', e);
|
||||
message.error({
|
||||
duration: null,
|
||||
content: 'Failed to download Flipper trace: ' + e,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
handle.close();
|
||||
});
|
||||
}
|
||||
throw new Error(UNKNOWN);
|
||||
|
||||
@@ -84,7 +84,6 @@ export type State = {
|
||||
share: ShareType | null;
|
||||
sessionId: string | null;
|
||||
serverPorts: ServerPorts;
|
||||
downloadingImportData: boolean;
|
||||
launcherMsg: LauncherMsg;
|
||||
statusMessages: Array<string>;
|
||||
xcodeCommandLineToolsDetected: boolean;
|
||||
@@ -94,8 +93,7 @@ export type State = {
|
||||
type BooleanActionType =
|
||||
| 'leftSidebarVisible'
|
||||
| 'rightSidebarVisible'
|
||||
| 'rightSidebarAvailable'
|
||||
| 'downloadingImportData';
|
||||
| 'rightSidebarAvailable';
|
||||
|
||||
export type Action =
|
||||
| {
|
||||
@@ -174,7 +172,6 @@ export const initialState: () => State = () => ({
|
||||
insecure: 8089,
|
||||
secure: 8088,
|
||||
},
|
||||
downloadingImportData: false,
|
||||
launcherMsg: {
|
||||
severity: 'warning',
|
||||
message: '',
|
||||
@@ -203,8 +200,7 @@ export default function reducer(
|
||||
if (
|
||||
action.type === 'leftSidebarVisible' ||
|
||||
action.type === 'rightSidebarVisible' ||
|
||||
action.type === 'rightSidebarAvailable' ||
|
||||
action.type === 'downloadingImportData'
|
||||
action.type === 'rightSidebarAvailable'
|
||||
) {
|
||||
const newValue =
|
||||
typeof action.payload === 'undefined'
|
||||
|
||||
Reference in New Issue
Block a user