Skip to content
Merged
18 changes: 12 additions & 6 deletions src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,25 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
/>
);

const tabs: SideContentTab[] = [
playgroundIntroductionTab,
listVisualizerTab,
inspectorTab,
envVisualizerTab
];
const tabs: SideContentTab[] = [playgroundIntroductionTab];

// Conditional logic for tab rendering
if (
this.props.externalLibraryName === ExternalLibraryNames.PIXNFLIX ||
this.props.externalLibraryName === ExternalLibraryNames.ALL
) {
// Enable video tab only when 'PIX&FLIX' is selected
tabs.push(videoDisplayTab);
}
if (this.props.sourceChapter >= 2) {
// Enable Data Visualizer for Source Chapter 2 and above
tabs.push(listVisualizerTab);
}
if (this.props.sourceChapter >= 3) {
// Enable Inspector, Env Visualizer for Source Chapter 3 and above
tabs.push(inspectorTab);
tabs.push(envVisualizerTab);
}

const workspaceProps: WorkspaceProps = {
controlBarProps: {
Expand Down
2 changes: 1 addition & 1 deletion src/sagas/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function* evalCode(
context.runtime.debuggerOn =
(actionType === actionTypes.EVAL_EDITOR || actionType === actionTypes.DEBUG_RESUME) &&
context.chapter > 2;
if (!context.runtime.debuggerOn) {
if (!context.runtime.debuggerOn && context.chapter > 2) {
Copy link
Contributor

@geshuming geshuming Aug 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this more logical, this part has always been making my brain explode.

const useDebugger = actionType !== actionTypes.EVAL_EDITOR && actionType !== actionTypes.DEBUG_RESUME && context.chapter > 2;

if (useDebugger) {
  inspectorUpdate(undefined);
}

Honestly though, I don't even think the above code segment makes any sense. Please comment on what this code segment is even intended to do.

Copy link
Contributor

@geshuming geshuming Aug 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, debuggerOn is used as a flag for slang.

So the correct code should look like

context.runtime.debuggerOn = (actionType === actionTypes.EVAL_EDITOR || actionType === actionTypes.DEBUG_RESUME) && context.chapter > 2;

if (context.runtime.debuggerOn) {
  // Resets the inspector to prepare for new output
  inspectorUpdate(undefined);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by the INSPECT team, so I'm not certain about how it works either. Having said that, this:

Okay, debuggerOn is used as a flag for slang.

So the correct code should look like

context.runtime.debuggerOn = (actionType === actionTypes.EVAL_EDITOR || actionType === actionTypes.DEBUG_RESUME) && context.chapter > 2;

if (context.runtime.debuggerOn) {
  // Resets the inspector to prepare for new output
  inspectorUpdate(undefined);
}

doesn't seem to be the same boolean expression as the original code. !(actionType === actionTypes.EVAL_EDITOR || actionType === actionTypes.DEBUG_RESUME) && context.chapter > 2 will call inspectorUpdate(undefined) in the original code, but not in the suggested amendment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. The clause should be

if (!context.runtime.debuggerOn)

just like the original code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this won't work because it can trigger inspectedUpdate(undefined) even when !(context.chapter > 2), and that crashes the entire webpage. That's what the change was originally for.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can we clean this up then. The logic here is very confusing. Can we add comments to clarify?

inspectorUpdate(undefined); // effectively resets the interface
}
const { result, interrupted, paused } = yield race({
Expand Down