Skip to content

Commit 476dfac

Browse files
small ux fixes and allow awaiting vscode effect
1 parent fe159c3 commit 476dfac

File tree

4 files changed

+40
-30
lines changed

4 files changed

+40
-30
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ const context: any = window;
7272
* parts.
7373
*/
7474
export class VSCodeEffect {
75-
// We should not need this as we load VSCode at effects level
76-
// private serviceCache: IServiceCache;
75+
public initialized: Promise<void>;
76+
7777
private monaco: any;
7878
private editorApi: any;
7979
private options: VsCodeOptions;
@@ -118,7 +118,7 @@ export class VSCodeEffect {
118118
// It will only load the editor once. We should probably call this
119119
const container = this.elements.editor;
120120

121-
return Promise.all([
121+
this.initialized = Promise.all([
122122
new Promise(resolve => {
123123
loadScript(['vs/editor/codesandbox.editor.main'])(resolve);
124124
}),
@@ -133,6 +133,8 @@ export class VSCodeEffect {
133133
getState: options.getState,
134134
}),
135135
]).then(() => this.loadEditor(window.monaco, container));
136+
137+
return this.initialized;
136138
}
137139

138140
public getEditorElement(

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
118118
actions.files.internal.recoverFiles();
119119
}
120120

121+
await effects.vscode.initialized;
122+
123+
effects.vscode.openModule(state.editor.currentModule);
124+
121125
state.editor.isLoading = false;
122126
});
123127

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,25 @@ export const Content: React.FC = () => {
185185
bottom: 0,
186186
}}
187187
>
188-
<Icons>
189-
{config && config.partialSupportDisclaimer ? (
190-
<Tooltip
191-
placement="bottom"
192-
content={config.partialSupportDisclaimer}
193-
style={{
194-
display: 'flex',
195-
'align-items': 'center',
196-
}}
197-
>
198-
Partially Supported Config{' '}
199-
<QuestionIcon style={{ marginLeft: '.5rem' }} />
200-
</Tooltip>
201-
) : null}
202-
{config && !config.partialSupportDisclaimer ? (
203-
<div>Supported Configuration</div>
204-
) : null}
205-
</Icons>
188+
{config ? (
189+
<Icons>
190+
{config.partialSupportDisclaimer ? (
191+
<Tooltip
192+
placement="bottom"
193+
content={config.partialSupportDisclaimer}
194+
style={{
195+
display: 'flex',
196+
'align-items': 'center',
197+
}}
198+
>
199+
Partially Supported Config{' '}
200+
<QuestionIcon style={{ marginLeft: '.5rem' }} />
201+
</Tooltip>
202+
) : (
203+
<div>Supported Configuration</div>
204+
)}
205+
</Icons>
206+
) : null}
206207
<CodeEditor key={sandbox.id} />
207208
</div>
208209
</div>

packages/app/src/app/pages/Sandbox/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import React from 'react';
2-
import Helmet from 'react-helmet';
3-
import { Link } from 'react-router-dom';
4-
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
51
import { Button } from '@codesandbox/common/lib/components/Button';
62
import Centered from '@codesandbox/common/lib/components/flex/Centered';
73
import Fullscreen from '@codesandbox/common/lib/components/flex/Fullscreen';
84
import Padding from '@codesandbox/common/lib/components/spacing/Padding';
5+
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
96
import { inject, observer } from 'app/componentConnectors';
10-
import { Title } from 'app/components/Title';
117
import { Skeleton } from 'app/components/Skeleton';
12-
import { QuickActions } from 'app/pages/Sandbox/QuickActions';
13-
import { NotFound } from 'app/pages/common/NotFound';
14-
import { Navigation } from 'app/pages/common/Navigation';
8+
import { Title } from 'app/components/Title';
159
import { GithubIntegration } from 'app/pages/common/GithubIntegration';
10+
import { Navigation } from 'app/pages/common/Navigation';
11+
import { NotFound } from 'app/pages/common/NotFound';
12+
import { QuickActions } from 'app/pages/Sandbox/QuickActions';
13+
import React from 'react';
14+
import Helmet from 'react-helmet';
15+
import { Link } from 'react-router-dom';
16+
1617
import Editor from './Editor';
1718

1819
class SandboxPage extends React.Component {
@@ -158,7 +159,9 @@ class SandboxPage extends React.Component {
158159
}}
159160
margin={1}
160161
>
161-
<Navigation title="Sandbox Editor" />
162+
{store.editor.isLoading ? null : (
163+
<Navigation title="Sandbox Editor" />
164+
)}
162165
<Centered
163166
style={{ flex: 1, width: '100%', height: '100%' }}
164167
horizontal

0 commit comments

Comments
 (0)