Skip to content

Commit fb808cc

Browse files
Add runnerBeingLoaded logic (#1205)
closes #1202
1 parent 8df5e6d commit fb808cc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
### Added
1010

1111
- `editor-projectLoadFailed` custom event that fires when a project completely fails to load (#1201)
12+
- Added runnerBeingLoaded state to prevent race condition overwrites (#1205)
1213

1314
### Fixed
1415

src/redux/EditorSlice.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const editorInitialState = {
140140
sidebarShowing: true,
141141
modals: {},
142142
errorDetails: {},
143+
runnerBeingLoaded: null | "pyodide" | "skulpt",
143144
};
144145

145146
export const EditorSlice = createSlice({
@@ -323,12 +324,15 @@ export const EditorSlice = createSlice({
323324
state.drawTriggered = false;
324325
},
325326
loadingRunner: (state, action) => {
327+
state.runnerBeingLoaded = action.payload;
326328
state.activeRunner = action.payload;
327329
state.codeRunLoading = true;
328330
},
329331
setLoadedRunner: (state, action) => {
330-
state.loadedRunner = action.payload;
331-
state.codeRunLoading = false;
332+
if (state.runnerBeingLoaded === action.payload) {
333+
state.loadedRunner = action.payload;
334+
state.codeRunLoading = false;
335+
}
332336
},
333337
resetRunner: (state) => {
334338
state.activeRunner = null;
@@ -339,6 +343,7 @@ export const EditorSlice = createSlice({
339343
state.codeRunLoading = false;
340344
state.codeRunTriggered = false;
341345
state.codeRunStopped = false;
346+
state.runnerBeingLoaded = null;
342347
},
343348
closeAccessDeniedWithAuthModal: (state) => {
344349
state.accessDeniedWithAuthModalShowing = false;

0 commit comments

Comments
 (0)