Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 72eb93b

Browse files
Łukasz SobekjasonLaster
authored andcommitted
Removes toJS from 3 action files (ast, breakpoints, addBreakpoint) (#5665)
1 parent 368520d commit 72eb93b

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

src/actions/ast.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ import type { ThunkArgs } from "./types";
2525

2626
export function setSourceMetaData(sourceId: SourceId) {
2727
return async ({ dispatch, getState }: ThunkArgs) => {
28-
const sourceRecord = getSource(getState(), sourceId);
29-
if (!sourceRecord) {
30-
return;
31-
}
32-
33-
const source = sourceRecord.toJS();
34-
if (!source.text || source.isWasm) {
28+
const source = getSource(getState(), sourceId);
29+
if (!source || !source.text || source.isWasm) {
3530
return;
3631
}
3732

@@ -48,19 +43,19 @@ export function setSourceMetaData(sourceId: SourceId) {
4843

4944
export function setSymbols(sourceId: SourceId) {
5045
return async ({ dispatch, getState }: ThunkArgs) => {
51-
const sourceRecord = getSource(getState(), sourceId);
52-
if (!sourceRecord) {
53-
return;
54-
}
55-
56-
const source = sourceRecord.toJS();
57-
if (!source.text || source.isWasm || hasSymbols(getState(), source)) {
46+
const source = getSource(getState(), sourceId);
47+
if (
48+
!source ||
49+
!source.text ||
50+
source.isWasm ||
51+
hasSymbols(getState(), source)
52+
) {
5853
return;
5954
}
6055

6156
await dispatch({
6257
type: "SET_SYMBOLS",
63-
source,
58+
source: source.toJS(),
6459
[PROMISE]: getSymbols(source.id)
6560
});
6661

@@ -94,22 +89,17 @@ export function setOutOfScopeLocations() {
9489

9590
export function setPausePoints(sourceId: SourceId) {
9691
return async ({ dispatch, getState, client }: ThunkArgs) => {
97-
const sourceRecord = getSource(getState(), sourceId);
98-
if (!sourceRecord) {
99-
return;
100-
}
101-
102-
const source = sourceRecord.toJS();
103-
if (!source.text || source.isWasm) {
92+
const source = getSource(getState(), sourceId);
93+
if (!source || !source.text || source.isWasm) {
10494
return;
10595
}
10696

10797
const pausePoints = await getPausePoints(source.id);
108-
await client.setPausePoints(sourceId, pausePoints);
98+
await client.setPausePoints(source.id, pausePoints);
10999

110100
dispatch({
111101
type: "SET_PAUSE_POINTS",
112-
source,
102+
source: source.toJS(),
113103
pausePoints
114104
});
115105
};

src/actions/breakpoints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export function toggleBreakpoint(line: ?number, column?: number) {
334334
const state = getState();
335335
const selectedSource = getSelectedSource(state);
336336
const bp = getBreakpointAtLocation(state, { line, column });
337-
const isEmptyLine = isEmptyLineInSource(state, line, selectedSource.toJS());
337+
const isEmptyLine = isEmptyLineInSource(state, line, selectedSource);
338338

339339
if ((!bp && isEmptyLine) || (bp && bp.loading)) {
340340
return;

src/actions/breakpoints/addBreakpoint.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ export default async function addBreakpoint(
2121
const state = getState();
2222

2323
const source = getSource(state, breakpoint.location.sourceId);
24-
const sourceRecord = source.toJS();
25-
const location = { ...breakpoint.location, sourceUrl: source.get("url") };
24+
const location = { ...breakpoint.location, sourceUrl: source.url };
2625
const generatedLocation = await getGeneratedLocation(
2726
state,
28-
sourceRecord,
27+
source.toJS(),
2928
location,
3029
sourceMaps
3130
);
@@ -50,8 +49,8 @@ export default async function addBreakpoint(
5049
newGeneratedLocation
5150
);
5251

53-
const symbols = getSymbols(getState(), sourceRecord);
54-
const astLocation = await getASTLocation(sourceRecord, symbols, newLocation);
52+
const symbols = getSymbols(getState(), source);
53+
const astLocation = await getASTLocation(source, symbols, newLocation);
5554

5655
const newBreakpoint = {
5756
id,

0 commit comments

Comments
 (0)