Skip to content

Commit e216328

Browse files
committed
Fix types
1 parent 36cbc51 commit e216328

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ export type OnFileChangeCallback = (data: OnFileChangeData) => void;
5151
export type OnOperationAppliedCallback = (data: OnOperationAppliedData) => void;
5252

5353
export type ModuleModel = {
54-
changeListener: { dispose: Function };
54+
changeListener: { dispose: Function } | null;
5555
currentLine: number;
5656
path: string;
57-
model: Promise<any>;
57+
model: Promise<any> | null;
5858
comments: Array<{ commentId: string; range: [number, number] }>;
5959
currentCommentDecorations: string[];
6060
};
@@ -91,8 +91,9 @@ export class ModelsHandler {
9191
this.modelAddedListener.dispose();
9292
this.modelRemovedListener.dispose();
9393
Object.keys(this.moduleModels).forEach(path => {
94-
if (this.moduleModels[path].changeListener) {
95-
this.moduleModels[path].changeListener.dispose();
94+
const changeListener = this.moduleModels[path].changeListener;
95+
if (changeListener) {
96+
changeListener.dispose();
9697
}
9798
});
9899
this.moduleModels = {};
@@ -300,7 +301,7 @@ export class ModelsHandler {
300301
public async setModuleCode(module: Module) {
301302
const moduleModel = this.getModuleModelByPath(module.path);
302303

303-
if (moduleModel?.model) {
304+
if (!moduleModel || !moduleModel.model) {
304305
return;
305306
}
306307
const model = await moduleModel.model;
@@ -706,7 +707,11 @@ export class ModelsHandler {
706707
this.modelRemovedListener = this.editorApi.textFileService.modelService.onModelRemoved(
707708
model => {
708709
if (this.moduleModels[model.uri.path]) {
709-
this.moduleModels[model.uri.path].changeListener.dispose();
710+
const changeListener = this.moduleModels[model.uri.path]
711+
.changeListener;
712+
if (changeListener) {
713+
changeListener.dispose();
714+
}
710715

711716
const csbPath = model.uri.path.replace('/sandbox', '');
712717
dispatch(actions.correction.clear(csbPath, 'eslint'));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const sendCurrentSelection: Action = ({ state, effects }) => {
186186
}
187187

188188
const { liveUserId } = state.live;
189-
if (liveUserId) {
189+
if (liveUserId && state.live.currentSelection) {
190190
effects.live.sendUserSelection(
191191
state.editor.currentModuleShortid,
192192
liveUserId,

0 commit comments

Comments
 (0)