Open
Bug 2083651
Opened 1 month ago
Updated 9 days ago
Consolidate all load source text methods into LOAD_SOURCE_TEXT
Categories
(DevTools :: Debugger, task, P3)
DevTools
Debugger
Tracking
(Not tracked)
NEW
People
(Reporter: bomsy, Unassigned)
References
(Blocks 1 open bug)
Details
Followup cleanup from https://phabricator.services.mozilla.com/D313158#
Instead of having three distinct actions (LOAD_HTML_SOURCE_TEXT, LOAD_ORIGINAL_SOURCE_TEXT, LOAD_GENERATED_SOURCE_TEXT), you may also unite into a unique action, similarly to what you did in the reducer.
Something along these lines:
dispatch(loadSourceText({ source, sourceActor }));
[...]
export const loadSourceText = memoizeableAction("loadSourceText", {
getValue: ({ source, sourceActor }, { getState }) => {
if (!source) {
return null;
}
const sourceTextContent = getSourceTextContentForSource(
getState(),
source,
sourceActor
);
if (!sourceTextContent || sourceTextContent.state === "pending") {
return sourceTextContent;
}
// This currently swallows source-load-failure since we return fulfilled
// here when content.state === "rejected". In an ideal world we should
// propagate that error upward.
return fulfilled(sourceTextContent);
},
createKey: ({ source, sourceActor }, { getState }) => {
const epoch = getSourcesEpoch(getState());
return `${epoch}:${source.id}-${sourceActor?.id}`;
},
action: (source, thunkArgs) => loadSourceTextPromise({ source, sourceActor }, thunkArgs),
});
async function loadSourceTextPromise({ source, sourceActor }, thunkArgs) {
const { dispatch, getState } = thunkArgs;
const epoch = getSourcesEpoch(getState());
await dispatch({
type: "LOAD_SOURCE_TEXT",
source,
sourceActor,
epoch,
[PROMISE]: loadSource(source, sourceActor, thunkArgs),
});
await onSourceTextContentAvailable(source, sourceActor, thunkArgs);
}
And then loadSource maps to loadGeneratedSource/loadOriginalSource/loadHtmlSource existing methods.
| Reporter | ||
Updated•9 days ago
|
Severity: -- → S3
Priority: -- → P3
You need to log in
before you can comment on or make changes to this bug.
Description
•