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

Commit 97aec24

Browse files
loganfsmythjasonLaster
authored andcommitted
Make getMappedExpression a real action and fix double-binding action creators (#5809)
1 parent ecc7891 commit 97aec24

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

src/actions/expressions.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function evaluateExpression(expression: Expression) {
114114
const frame = getSelectedFrame(getState());
115115

116116
if (frame) {
117-
const { location, generatedLocation } = frame;
117+
const { location } = frame;
118118
const source = getSource(getState(), location.sourceId);
119119
const sourceId = source.get("id");
120120

@@ -125,11 +125,7 @@ function evaluateExpression(expression: Expression) {
125125
!isGeneratedId(sourceId) &&
126126
!isGeneratedId(selectedSource.get("id"))
127127
) {
128-
input = await getMappedExpression(
129-
{ getState, sourceMaps },
130-
generatedLocation,
131-
input
132-
);
128+
input = await dispatch(getMappedExpression(input));
133129
}
134130
}
135131

@@ -147,15 +143,16 @@ function evaluateExpression(expression: Expression) {
147143
* Gets information about original variable names from the source map
148144
* and replaces all posible generated names.
149145
*/
150-
export async function getMappedExpression(
151-
{ getState, sourceMaps }: Object,
152-
generatedLocation: Location,
153-
expression: string
154-
): Promise<string> {
155-
const mappings = getSelectedScopeMappings(getState());
156-
if (!mappings) {
157-
return expression;
158-
}
159-
160-
return await parser.mapOriginalExpression(expression, mappings);
146+
export function getMappedExpression(expression: string) {
147+
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
148+
const mappings = getSelectedScopeMappings(getState());
149+
if (!mappings) {
150+
return expression;
151+
}
152+
153+
return await dispatch({
154+
type: "MAP_EXPRESSION_RESULT",
155+
[PROMISE]: parser.mapOriginalExpression(expression, mappings)
156+
});
157+
};
161158
}

src/actions/preview.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,7 @@ export function setPreview(
173173

174174
const sourceId = source.get("id");
175175
if (location && !isGeneratedId(sourceId)) {
176-
const generatedLocation = await sourceMaps.getGeneratedLocation(
177-
{ ...location.start, sourceId },
178-
source.toJS()
179-
);
180-
181-
expression = await getMappedExpression(
182-
{ sourceMaps, getState },
183-
generatedLocation,
184-
expression
185-
);
176+
expression = await dispatch(getMappedExpression(expression));
186177
}
187178

188179
const selectedFrame = getSelectedFrame(getState());

src/utils/dbg.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { bindActionCreators } from "redux";
21
import * as timings from "./timings";
32
import { prefs, features } from "./prefs";
43
import { isDevelopment } from "devtools-config";
@@ -52,11 +51,9 @@ function _formatPausePoints(dbg, url) {
5251

5352
export function setupHelper(obj) {
5453
const selectors = bindSelectors(obj);
55-
const actions = bindActionCreators(obj.actions, obj.store.dispatch);
5654
const dbg = {
5755
...obj,
5856
selectors,
59-
actions,
6057
prefs,
6158
features,
6259
timings,

0 commit comments

Comments
 (0)