Skip to content

Commit d85405c

Browse files
jasonLasterdarkwing
authored andcommitted
[sources] update newSources filter check (firefox-devtools#6778)
1 parent 9059b45 commit d85405c

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

src/actions/sources/newSources.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ function loadSourceMaps(sources) {
5151
return;
5252
}
5353

54-
const originalSources = await Promise.all(
55-
sources.map(source => dispatch(loadSourceMap(source.id)))
54+
let originalSources = await Promise.all(
55+
sources.map(({ id }) => dispatch(loadSourceMap(id)))
5656
);
5757

58-
await dispatch(newSources(flatten(originalSources)));
58+
originalSources = flatten(originalSources).filter(Boolean);
59+
if (originalSources.length > 0) {
60+
await dispatch(newSources(originalSources));
61+
}
5962
};
6063
}
6164

@@ -172,30 +175,23 @@ export function newSource(source: Source) {
172175

173176
export function newSources(sources: Source[]) {
174177
return async ({ dispatch, getState }: ThunkArgs) => {
175-
const filteredSources = sources.filter(
176-
source => source && !getSource(getState(), source.id)
177-
);
178+
sources = sources.filter(source => !getSource(getState(), source.id));
178179

179-
if (filteredSources.length == 0) {
180+
if (sources.length == 0) {
180181
return;
181182
}
182183

183-
dispatch(
184-
({
185-
type: "ADD_SOURCES",
186-
sources: filteredSources
187-
}: Action)
188-
);
184+
dispatch(({ type: "ADD_SOURCES", sources: sources }: Action));
189185

190-
for (const source of filteredSources) {
186+
for (const source of sources) {
191187
dispatch(checkSelectedSource(source.id));
192188
dispatch(checkPendingBreakpoints(source.id));
193189
}
194190

195-
await dispatch(loadSourceMaps(filteredSources));
191+
await dispatch(loadSourceMaps(sources));
196192

197193
// We would like to restore the blackboxed state
198194
// after loading all states to make sure the correctness.
199-
await dispatch(restoreBlackBoxedSources(filteredSources));
195+
await dispatch(restoreBlackBoxedSources(sources));
200196
};
201197
}

0 commit comments

Comments
 (0)