Skip to content

Commit 02841b6

Browse files
remo5000ning-y
authored andcommitted
Hotfix "Stop" button (#262)
* Remove EVAL_EDITOR and EVAL_REPL reducers These run before the saga * Add isRunning property to IWorkspaceState * Modify EVAL reducer cases to set isRunning to true or false. * Modify containers to use isRunning from workspace * Format reducer
1 parent d27e7b9 commit 02841b6

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/containers/PlaygroundContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const mapStateToProps: MapStateToProps<IStateProps, {}, IState> = state => ({
2727
activeTab: state.workspaces.playground.sideContentActiveTab,
2828
editorWidth: state.workspaces.playground.editorWidth,
2929
editorValue: state.workspaces.playground.editorValue!,
30-
isRunning: state.workspaces.playground.context.runtime.isRunning,
30+
isRunning: state.workspaces.playground.isRunning,
3131
output: state.workspaces.playground.output,
3232
queryString: state.playground.queryString,
3333
replValue: state.workspaces.playground.replValue,

src/containers/academy/grading/GradingWorkspaceContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const mapStateToProps: MapStateToProps<StateProps, OwnProps, IState> = (state, p
4040
editorWidth: state.workspaces.grading.editorWidth,
4141
grading: state.session.gradings.get(props.submissionId),
4242
hasUnsavedChanges: state.workspaces.grading.hasUnsavedChanges,
43-
isRunning: state.workspaces.grading.context.runtime.isRunning,
43+
isRunning: state.workspaces.grading.isRunning,
4444
output: state.workspaces.grading.output,
4545
replValue: state.workspaces.grading.replValue,
4646
sideContentHeight: state.workspaces.grading.sideContentHeight,

src/containers/assessment/AssessmentWorkspaceContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const mapStateToProps: MapStateToProps<StateProps, OwnProps, IState> = (state, p
3939
editorValue: state.workspaces.assessment.editorValue,
4040
editorWidth: state.workspaces.assessment.editorWidth,
4141
hasUnsavedChanges: state.workspaces.assessment.hasUnsavedChanges,
42-
isRunning: state.workspaces.assessment.context.runtime.isRunning,
42+
isRunning: state.workspaces.assessment.isRunning,
4343
output: state.workspaces.assessment.output,
4444
replValue: state.workspaces.assessment.replValue,
4545
sideContentHeight: state.workspaces.assessment.sideContentHeight,

src/reducers/states.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface IWorkspaceState {
6060
readonly context: Context
6161
readonly editorValue: string | null
6262
readonly editorWidth: string
63+
readonly isRunning: boolean
6364
readonly output: InterpreterOutput[]
6465
readonly replHistory: ReplHistory
6566
readonly replValue: string
@@ -197,7 +198,8 @@ export const createDefaultWorkspace = (location: WorkspaceLocation): IWorkspaceS
197198
replValue: '',
198199
sideContentActiveTab: 0,
199200
externalSymbols: [],
200-
globals: []
201+
globals: [],
202+
isRunning: false
201203
})
202204

203205
export const defaultComments = 'Comments **here**. Use `markdown` if you ~~are cool~~ want!'

src/reducers/workspaces.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
261261
playground: playgroundWorkspace
262262
}
263263
case EVAL_EDITOR:
264-
// Forces re-render of workspace on editor eval
265264
return {
266265
...state,
267266
[location]: {
268-
...state[location]
267+
...state[location],
268+
isRunning: true
269269
}
270270
}
271271
case EVAL_REPL:
272-
// Forces re-render of workspace on editor eval
273272
return {
274273
...state,
275274
[location]: {
276-
...state[location]
275+
...state[location],
276+
isRunning: true
277277
}
278278
}
279279
case EVAL_INTERPRETER_SUCCESS:
@@ -295,7 +295,8 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
295295
...state,
296296
[location]: {
297297
...state[location],
298-
output: newOutput
298+
output: newOutput,
299+
isRunning: false
299300
}
300301
}
301302
case EVAL_INTERPRETER_ERROR:
@@ -317,7 +318,8 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
317318
...state,
318319
[location]: {
319320
...state[location],
320-
output: newOutput
321+
output: newOutput,
322+
isRunning: false
321323
}
322324
}
323325
/**
@@ -337,10 +339,7 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
337339
...state,
338340
[location]: {
339341
...state[location],
340-
context: {
341-
...state[location].context,
342-
isRunning: false
343-
}
342+
isRunning: false
344343
}
345344
}
346345
/**

0 commit comments

Comments
 (0)