Skip to content

Commit 88e3964

Browse files
author
Ives van Hoorne
committed
Fix bug with requesting new sandbox
1 parent 7fbf3a4 commit 88e3964

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

src/app/components/sandbox/CodeEditor/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ const handleError = (cm, currentError, nextError, nextCode, nextId) => {
6868
export default class CodeEditor extends React.PureComponent {
6969
props: Props;
7070

71-
constructor(props) {
72-
super(props);
73-
74-
this.handleChange = debounce(this.handleChange, 200);
75-
}
76-
7771
shouldComponentUpdate(nextProps: Props) {
7872
return nextProps.id !== this.props.id ||
7973
nextProps.error !== this.props.error ||
@@ -94,7 +88,7 @@ export default class CodeEditor extends React.PureComponent {
9488
nextTitle: string,
9589
}
9690
) => {
97-
if (nextId !== currentId) {
91+
if (nextId !== currentId || nextCode !== this.getCode()) {
9892
if (!documentCache[nextId]) {
9993
const mode = await this.getMode(nextTitle);
10094

src/app/components/sandbox/Preview/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class Preview extends React.PureComponent {
6363
url: null,
6464
};
6565

66-
this.executeCode = debounce(this.executeCode, 400);
66+
this.executeCode = debounce(this.executeCode, 800);
6767
}
6868

6969
fetchBundle = () => {
@@ -109,10 +109,7 @@ export default class Preview extends React.PureComponent {
109109
prevProps.directories !== this.props.directories) &&
110110
this.state.frameInitialized
111111
) {
112-
if (
113-
this.props.preferences.livePreviewEnabled &&
114-
prevProps.bundle === this.props.bundle
115-
) {
112+
if (this.props.preferences.livePreviewEnabled) {
116113
this.executeCode();
117114
}
118115
}

src/app/pages/Sandbox/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class SandboxPage extends React.PureComponent {
7373

7474
if (newId != null && oldId !== newId) {
7575
this.setState({ notFound: false });
76-
if (!this.props.sandboxes[newId]) {
76+
if (!this.props.sandboxes[newId] || !this.props.sandboxes[newId].forked) {
7777
this.fetchSandbox();
7878
}
7979
}

src/app/store/entities/sandboxes/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const forkSandbox = (id: string) => async (
122122
if (currentSandbox) {
123123
data.currentModule = currentSandbox.currentModule;
124124
}
125+
data.forked = true;
125126
await dispatch(normalizeResult(entity, data));
126127

127128
dispatch(push(sandboxUrl(data)));

0 commit comments

Comments
 (0)