Skip to content

Commit f092262

Browse files
fix typings and smoother module selection
1 parent f4474e7 commit f092262

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,19 @@ export class VSCodeEffect {
303303
public async openModule(module: Module) {
304304
await this.initialized;
305305

306-
try {
307-
const model = await this.modelsHandler.changeModule(module);
308-
309-
this.lint(module.title, model);
310-
} catch (error) {
311-
// We might try to open a module that is not actually opened in the editor,
312-
// but the configuration wizard.. currently this throws an error as there
313-
// is really no good way to identify when it happen. This needs to be
314-
// improved in next version
315-
}
306+
// We open this on the next tick to allow a UI update to occur first
307+
setTimeout(async () => {
308+
try {
309+
const model = await this.modelsHandler.changeModule(module);
310+
311+
this.lint(module.title, model);
312+
} catch (error) {
313+
// We might try to open a module that is not actually opened in the editor,
314+
// but the configuration wizard.. currently this throws an error as there
315+
// is really no good way to identify when it happen. This needs to be
316+
// improved in next version
317+
}
318+
});
316319
}
317320

318321
setErrors = (errors: ModuleError[]) => {

packages/app/src/app/overmind/internalActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export const ensurePackageJSON: AsyncAction = async ({ state, effects }) => {
317317
// We grab the module from the state to continue working with it (proxy)
318318
const module = sandbox.modules[sandbox.modules.length - 1];
319319

320-
effects.vscode.fs.writeFile(state.editor.modulesByPath, module);
320+
effects.vscode.sandboxFsSync.writeFile(state.editor.modulesByPath, module);
321321

322322
try {
323323
const updatedModule = await effects.api.createModule(sandbox.id, module);
@@ -326,7 +326,7 @@ export const ensurePackageJSON: AsyncAction = async ({ state, effects }) => {
326326
module.shortid = updatedModule.shortid;
327327
} catch (error) {
328328
sandbox.modules.splice(sandbox.modules.indexOf(module), 1);
329-
state.editor.modulesByPath = effects.vscode.fs.create(sandbox);
329+
state.editor.modulesByPath = effects.vscode.sandboxFsSync.create(sandbox);
330330
}
331331
}
332332
};

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export const roomJoined: AsyncAction<{
2828

2929
state.workspace.openedWorkspaceItem = defaultItem.id;
3030

31-
state.editor.modulesByPath = await effects.vscode.changeSandbox(
32-
state.editor.currentSandbox
33-
);
34-
effects.vscode.syncTypings();
31+
await effects.vscode.changeSandbox(state.editor.currentSandbox, fs => {
32+
state.editor.modulesByPath = fs;
33+
});
34+
3535
effects.vscode.openModule(state.editor.currentModule);
3636
effects.preview.executeCodeImmediately(true);
3737
state.live.isLoading = false;
@@ -48,9 +48,9 @@ export const createLiveClicked: AsyncAction<{
4848
const sandbox = await actions.live.internal.initialize(roomId);
4949
actions.internal.setCurrentSandbox(sandbox);
5050

51-
state.editor.modulesByPath = await effects.vscode.changeSandbox(
52-
state.editor.currentSandbox
53-
);
51+
await effects.vscode.changeSandbox(state.editor.currentSandbox, fs => {
52+
state.editor.modulesByPath = fs;
53+
});
5454

5555
effects.vscode.openModule(state.editor.currentModule);
5656
effects.preview.executeCodeImmediately(true);

0 commit comments

Comments
 (0)