[blackbox] blackbox and pretty print sources should be persisted
It would be great if we could persist blackbox state like we persist tabs. This way, when you come back, the same sources are still blackboxed.
This is a start on this issue:
diff --git a/src/actions/sources.js b/src/actions/sources.js
index 5e644db3..6027e169 100644
--- a/src/actions/sources.js
+++ b/src/actions/sources.js
@@ -92,6 +92,7 @@ export function newSource(source: Source) {
}
await checkSelectedSource(getState(), dispatch, source);
+ await checkPendingTabs(getState(), dispatch, source); // this should restore blackbox state for sources
await checkPendingBreakpoints(getState(), dispatch, source);
};
}
@@ -244,10 +245,10 @@ export function addTab(source: Source, tabIndex: number) {
};
}
-export function moveTab(url: string, tabIndex: number) {
+export function moveTab(source: Source, tabIndex: number) {
return {
type: "MOVE_TAB",
- url,
+ source,
tabIndex
};
}
diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index 2004e4d8..a5add58b 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -301,7 +301,7 @@ class SourceTabs extends PureComponent {
const hiddenSourceTabs = getHiddenTabs(sourceTabs, sourceTabEls);
if (isVisible() && hiddenSourceTabs.indexOf(selectedSource) !== -1) {
- return moveTab(selectedSource.get("url"), 0);
+ return moveTab(selectedSource.toJS(), 0);
}
this.setState({ hiddenSourceTabs });
@@ -319,7 +319,7 @@ class SourceTabs extends PureComponent {
const onClick = () => {
const tabIndex = 0;
- moveTab(source.get("url"), tabIndex);
+ moveTab(source.toJS(), tabIndex);
};
return (
<li key={source.get("id")} onClick={onClick}>
diff --git a/src/reducers/sources.js b/src/reducers/sources.js
index ddb14e34..929a69dd 100644
--- a/src/reducers/sources.js
+++ b/src/reducers/sources.js
@@ -102,12 +102,12 @@ function update(
case "ADD_TAB":
return state.merge({
- tabs: updateTabList({ sources: state }, action.source.url)
+ tabs: updateTabList({ sources: state }, action.source)
});
case "MOVE_TAB":
return state.merge({
- tabs: updateTabList({ sources: state }, action.url, action.tabIndex)
+ tabs: updateTabList({ sources: state }, action.source, action.tabIndex)
});
case "CLOSE_TAB":
@@ -203,18 +203,20 @@ function restoreTabs() {
* @memberof reducers/sources
* @static
*/
-function updateTabList(state: OuterState, url: ?string, tabIndex?: number) {
+function updateTabList(state: OuterState, source: ?Object, tabIndex?: number) {
let tabs = state.sources.get("tabs");
- const urlIndex = tabs.indexOf(url);
- const includesUrl = !!tabs.find(tab => tab == url);
+ const urlIndex = tabs.indexOf(source.url);
+ const includesUrl = !!tabs.find(tab => tab.url == source.url);
+ const { url, isBlackboxed } = source;
+ const tab = { url, isBlackboxed }
if (includesUrl) {
if (tabIndex != undefined) {
- tabs = tabs.delete(urlIndex).insert(tabIndex, url);
+ tabs = tabs.delete(urlIndex).insert(tabIndex, tab);
}
} else {
- tabs = tabs.insert(0, url);
+ tabs = tabs.insert(0, tab);
}
prefs.tabs = tabs.toJS();
@@ -350,7 +352,7 @@ export const getSourcesForTabs = createSelector(
getSources,
(tabs: TabList, sources: SourcesMap) => {
return tabs
- .map(tab => getSourceByUrlInSources(sources, tab))
+ .map(tab => getSourceByUrlInSources(sources, tab.url))
.filter(source => source);
}
);
@jasonLaster @codehag I would like to tackle this bug. That would be kind of you that you could feedback on some questions, thanks:
- What is the blackboxed state?
- I found
checkPendingTabsdoesn't exist so it looks like we have to implement it. What is the purpose of this function, checking what "pending" tabs? I could foundTabList[1] in the state's sources, which carries js sources even beyond the todo-mvc website (or "tab") at which I am debugging, see the screenshot below. Guess that tab list is what we should check?
[1] https://github.com/devtools-html/debugger.html/blob/c6fe43a2870c08feb985d5e1a2af4629389ea6ad/src/reducers/sources.js#L33
Hey @Fischer-L I'm so sorry i missed this. In general, you should ping us in slack if you haven't heard from us.
I think this issue is a bit too complicated for a new comer... lets find another issue
ok, thanks
I am grabbing it
/unclaim
Done :+1:
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
@Fischer-L how is this going?
@bomsy
how is this going?
Working on this. Sorry for the slow progress because the busy day jobs and the vacations at end of the year
Status update (so we know this issue is still moving):
- Done: save the prefs tabs with the BlackBoxed state, which is
{ url, isBlackBoxed } - To go: test the BlackBoxed state can be restored successfully
nice, maybe PR the prefs work?
Hey @Fischer-L how's it going?
Hey @Fischer-L how's it going?
@jasonLaster during testing I found some difficulties so I am trying another approach. Will update soon.
@jasonLaster PR #5195 is created for persisting the blackbox states, thanks.
And would like to check another question about persisting the pretty print.
Below tried to pretty print one script then after reloading, the pretty printed script still existed. For persisting pretty print what behavior is expected here?

oh interesting. I think that is the expected behavior :)
@Fischer-L still interested in this?
@Fischer-L still interested in this?
Yes, will rebase and update again.
thanks! also, do you have an issue/pr for the redux toggle all bps? @nyrosmith added a PR for this recently too...