Skip to content

Commit dd109d0

Browse files
committed
Remove legacy SSE code from preview listener
1 parent 76f38dc commit dd109d0

File tree

2 files changed

+11
-6
lines changed
  • packages
    • app/src/app/pages/Sandbox/Editor/Content/Preview
    • common/src/components/Preview

2 files changed

+11
-6
lines changed

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ class Preview extends Component<Props, State> {
124124
handleModuleSyncedChange = (preview, change) => {
125125
const settings = this.props.store.preferences.settings;
126126

127-
if (settings.livePreviewEnabled && change) {
128-
if (this.props.store.editor.currentSandbox.template === 'static') {
129-
preview.handleRefresh();
130-
} else {
131-
preview.executeCodeImmediately();
132-
}
127+
if (
128+
settings.livePreviewEnabled &&
129+
change &&
130+
this.props.store.editor.currentSandbox.template === 'static'
131+
) {
132+
preview.handleRefresh();
133133
}
134134
};
135135

packages/common/src/components/Preview/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ class BasePreview extends React.Component<Props, State> {
359359
};
360360

361361
executeCodeImmediately = (initialRender: boolean = false) => {
362+
// We cancel the existing calls with executeCode to prevent concurrent calls,
363+
// the only reason we do this is because executeCodeImmediately can be called
364+
// directly as well
365+
// @ts-ignore
366+
this.executeCode.cancel();
362367
const settings = this.props.settings;
363368
const sandbox = this.props.sandbox;
364369

0 commit comments

Comments
 (0)