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,
|
ACTIVE_SHEET_SIGN_IN,
|
||||||
setActiveSheet,
|
setActiveSheet,
|
||||||
setPastedToken,
|
setPastedToken,
|
||||||
toggleAction,
|
|
||||||
} from './reducers/application';
|
} from './reducers/application';
|
||||||
import {Group, SUPPORTED_GROUPS} from './reducers/supportForm';
|
import {Group, SUPPORTED_GROUPS} from './reducers/supportForm';
|
||||||
import {Store} from './reducers/index';
|
import {Store} from './reducers/index';
|
||||||
@@ -19,6 +18,7 @@ import {importDataToStore} from './utils/exportData';
|
|||||||
import {selectPlugin} from './reducers/connections';
|
import {selectPlugin} from './reducers/connections';
|
||||||
import {Dialog} from 'flipper-plugin';
|
import {Dialog} from 'flipper-plugin';
|
||||||
import {handleOpenPluginDeeplink} from './dispatcher/handleOpenPluginDeeplink';
|
import {handleOpenPluginDeeplink} from './dispatcher/handleOpenPluginDeeplink';
|
||||||
|
import {message} from 'antd';
|
||||||
|
|
||||||
const UNKNOWN = 'Unknown deeplink';
|
const UNKNOWN = 'Unknown deeplink';
|
||||||
/**
|
/**
|
||||||
@@ -37,18 +37,22 @@ export async function handleDeeplink(
|
|||||||
}
|
}
|
||||||
if (uri.pathname.match(/^\/*import\/*$/)) {
|
if (uri.pathname.match(/^\/*import\/*$/)) {
|
||||||
const url = uri.searchParams.get('url');
|
const url = uri.searchParams.get('url');
|
||||||
store.dispatch(toggleAction('downloadingImportData', true));
|
|
||||||
if (url) {
|
if (url) {
|
||||||
|
const handle = Dialog.loading({
|
||||||
|
message: 'Importing Flipper trace...',
|
||||||
|
});
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((data) => importDataToStore(url, data, store))
|
.then((data) => importDataToStore(url, data, store))
|
||||||
.then(() => {
|
|
||||||
store.dispatch(toggleAction('downloadingImportData', false));
|
|
||||||
})
|
|
||||||
.catch((e: Error) => {
|
.catch((e: Error) => {
|
||||||
console.error('Failed to download Flipper trace' + e);
|
console.warn('Failed to download Flipper trace', e);
|
||||||
store.dispatch(toggleAction('downloadingImportData', false));
|
message.error({
|
||||||
throw e;
|
duration: null,
|
||||||
|
content: 'Failed to download Flipper trace: ' + e,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
handle.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw new Error(UNKNOWN);
|
throw new Error(UNKNOWN);
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ export type State = {
|
|||||||
share: ShareType | null;
|
share: ShareType | null;
|
||||||
sessionId: string | null;
|
sessionId: string | null;
|
||||||
serverPorts: ServerPorts;
|
serverPorts: ServerPorts;
|
||||||
downloadingImportData: boolean;
|
|
||||||
launcherMsg: LauncherMsg;
|
launcherMsg: LauncherMsg;
|
||||||
statusMessages: Array<string>;
|
statusMessages: Array<string>;
|
||||||
xcodeCommandLineToolsDetected: boolean;
|
xcodeCommandLineToolsDetected: boolean;
|
||||||
@@ -94,8 +93,7 @@ export type State = {
|
|||||||
type BooleanActionType =
|
type BooleanActionType =
|
||||||
| 'leftSidebarVisible'
|
| 'leftSidebarVisible'
|
||||||
| 'rightSidebarVisible'
|
| 'rightSidebarVisible'
|
||||||
| 'rightSidebarAvailable'
|
| 'rightSidebarAvailable';
|
||||||
| 'downloadingImportData';
|
|
||||||
|
|
||||||
export type Action =
|
export type Action =
|
||||||
| {
|
| {
|
||||||
@@ -174,7 +172,6 @@ export const initialState: () => State = () => ({
|
|||||||
insecure: 8089,
|
insecure: 8089,
|
||||||
secure: 8088,
|
secure: 8088,
|
||||||
},
|
},
|
||||||
downloadingImportData: false,
|
|
||||||
launcherMsg: {
|
launcherMsg: {
|
||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
message: '',
|
message: '',
|
||||||
@@ -203,8 +200,7 @@ export default function reducer(
|
|||||||
if (
|
if (
|
||||||
action.type === 'leftSidebarVisible' ||
|
action.type === 'leftSidebarVisible' ||
|
||||||
action.type === 'rightSidebarVisible' ||
|
action.type === 'rightSidebarVisible' ||
|
||||||
action.type === 'rightSidebarAvailable' ||
|
action.type === 'rightSidebarAvailable'
|
||||||
action.type === 'downloadingImportData'
|
|
||||||
) {
|
) {
|
||||||
const newValue =
|
const newValue =
|
||||||
typeof action.payload === 'undefined'
|
typeof action.payload === 'undefined'
|
||||||
|
|||||||
Reference in New Issue
Block a user