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

Commit

Permalink
touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster committed Nov 18, 2017
1 parent d88b4ee commit d1c63b5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/actions/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ export function newSource(source: Source) {
dispatch({ type: "ADD_SOURCE", source });

if (prefs.clientSourceMapsEnabled) {
await dispatch(loadSourceMap(source));
dispatch(loadSourceMap(source));
}

await checkSelectedSource(getState(), dispatch, source);
await checkPendingBreakpoints(getState(), dispatch, source.id);
checkSelectedSource(getState(), dispatch, source);
checkPendingBreakpoints(getState(), dispatch, source.id);
};
}

Expand All @@ -109,8 +109,15 @@ export function newSources(sources: Source[]) {
source => !getSource(getState(), source.id)
);

dispatch({
type: "ADD_SOURCES",
sources
});

for (const source of filteredSources) {
await dispatch(newSource(source));
dispatch(loadSourceMap(source));
checkSelectedSource(getState(), dispatch, source);
checkPendingBreakpoints(getState(), dispatch, source.id);
}
};
}
Expand Down
12 changes: 11 additions & 1 deletion src/client/firefox/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
Actions
} from "./types";

import { throttle } from "lodash";
import { createPause, createSource } from "./create";
import { isEnabled } from "devtools-config";

Expand Down Expand Up @@ -61,8 +62,17 @@ function resumed(_: "resumed", packet: ResumedPacket) {
actions.resumed(packet);
}
let pendingSources = [];
const newSources = throttle(() => {
actions.newSources(
pendingSources.map(source => createSource(source, { supportsWasm }))
);
pendingSources = [];
}, 100);
function newSource(_: "newSource", { source }: SourcePacket) {
actions.newSource(createSource(source, { supportsWasm }));
pendingSources.push(source);
newSources();
if (isEnabled("eventListeners")) {
actions.fetchEventListeners();
Expand Down
2 changes: 1 addition & 1 deletion src/client/firefox/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export type ListTabsResponse = {
export type Actions = {
paused: Pause => void,
resumed: ResumedPacket => void,
newSource: Source => void,
newSources: (Source[]) => void,
fetchEventListeners: () => void
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class Editor extends PureComponent<Props, State> {
}

componentWillUpdate(nextProps) {
console.warn("Editor.componentWillUpdate");
this.setText(nextProps);
this.setSize(nextProps);
}
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ export function getPreview(state: OuterState) {
return state.ast.get("preview");
}

const emptySourceMetaData = {};
export function getSourceMetaData(state: OuterState, sourceId: string) {
return state.ast.getIn(["sourceMetaData", sourceId]) || {};
return state.ast.getIn(["sourceMetaData", sourceId]) || emptySourceMetaData;
}

export default update;

0 comments on commit d1c63b5

Please sign in to comment.