File tree 4 files changed +16
-10
lines changed
packages/react-devtools-shared/src/devtools 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,11 @@ export default class Store extends EventEmitter<{|
416
416
}
417
417
418
418
getElementByID ( id : number ) : Element | null {
419
+ if (
420
+ this . _profilerStore . _dataFrontend &&
421
+ this . _profilerStore . _dataFrontend . imported === true
422
+ )
423
+ return null ;
419
424
const element = this . _idToElement . get ( id ) ;
420
425
if ( element == null ) {
421
426
console . warn ( `No element found with id "${ id } "` ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import ButtonIcon from '../ButtonIcon';
16
16
import { StoreContext } from '../context' ;
17
17
import {
18
18
prepareProfilingDataExport ,
19
- prepareProfilingDataFrontendFromExport ,
19
+ prepareProfilingDataFrontendFromImport ,
20
20
} from './utils' ;
21
21
import { downloadFile } from '../utils' ;
22
22
@@ -77,11 +77,11 @@ export default function ProfilingImportExportButtons() {
77
77
fileReader . addEventListener ( 'load' , ( ) => {
78
78
try {
79
79
const raw = ( ( fileReader . result : any ) : string ) ;
80
- const profilingDataExport = ( ( JSON . parse (
80
+ const profilingDataImport = ( ( JSON . parse (
81
81
raw ,
82
82
) : any ) : ProfilingDataExport ) ;
83
- profilerStore . profilingData = prepareProfilingDataFrontendFromExport (
84
- profilingDataExport ,
83
+ profilerStore . profilingData = prepareProfilingDataFrontendFromImport (
84
+ profilingDataImport ,
85
85
) ;
86
86
} catch ( error ) {
87
87
modalDialogDispatch ( {
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ export type ProfilingDataForRootFrontend = {|
105
105
export type ProfilingDataFrontend = { |
106
106
// Profiling data per root.
107
107
dataForRoots : Map < number , ProfilingDataForRootFrontend> ,
108
+ imported : boolean ,
108
109
| } ;
109
110
110
111
export type CommitDataExport = { |
Original file line number Diff line number Diff line change @@ -99,21 +99,21 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
99
99
) ;
100
100
} ) ;
101
101
102
- return { dataForRoots } ;
102
+ return { dataForRoots , imported : false } ;
103
103
}
104
104
105
105
// Converts a Profiling data export into the format required by the Store.
106
- export function prepareProfilingDataFrontendFromExport (
107
- profilingDataExport : ProfilingDataExport ,
106
+ export function prepareProfilingDataFrontendFromImport (
107
+ profilingDataImport : ProfilingDataExport ,
108
108
) : ProfilingDataFrontend {
109
- const { version } = profilingDataExport ;
109
+ const { version } = profilingDataImport ;
110
110
111
111
if ( version !== PROFILER_EXPORT_VERSION ) {
112
112
throw Error ( `Unsupported profiler export version "${ version } "` ) ;
113
113
}
114
114
115
115
const dataForRoots : Map < number , ProfilingDataForRootFrontend > = new Map ( ) ;
116
- profilingDataExport . dataForRoots . forEach (
116
+ profilingDataImport . dataForRoots . forEach (
117
117
( {
118
118
commitData,
119
119
displayName,
@@ -156,7 +156,7 @@ export function prepareProfilingDataFrontendFromExport(
156
156
} ,
157
157
) ;
158
158
159
- return { dataForRoots } ;
159
+ return { dataForRoots , imported : true } ;
160
160
}
161
161
162
162
// Converts a Store Profiling data into a format that can be safely (JSON) serialized for export.
You can’t perform that action at this time.
0 commit comments