Skip to content

Commit 53adb76

Browse files
author
Ives van Hoorne
committed
Fix many code updating bugs
1 parent 6b84372 commit 53adb76

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
397397
nextId: newModule.id,
398398
nextTitle: newModule.title,
399399
}).then(() => {
400+
// Mark as receiving code so we don't send operations to others because
401+
// of a module switch
402+
this.receivingCode = true;
400403
if (newModule === this.currentModule) {
401404
this.changeCode(newModule.code || '');
402405
}
@@ -414,6 +417,7 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
414417
// that the changes of code are not sent to live users. We need to reset
415418
// this state when we're doing changing modules
416419
this.props.onCodeReceived();
420+
this.receivingCode = false;
417421
}
418422
});
419423
};
@@ -798,6 +802,12 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
798802
module.id
799803
);
800804

805+
if (path === '') {
806+
// Parent dir got deleted
807+
this.disposeModel(module.id);
808+
return;
809+
}
810+
801811
// Check for changed path, if that's
802812
// the case create a new model with corresponding tag, ditch the other model
803813
if (path !== modelCache[module.id].model.uri.path) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ class EditorPreview extends React.Component<Props, State> {
269269
const corrections = store.editor.corrections.map(e => e);
270270
changeModule(newModule, errors, corrections);
271271
} else if (editor.changeCode) {
272+
// Only code changed from outside the editor
272273
editor.changeCode(newModule.code || '');
273274
}
274275
}

packages/app/src/app/store/modules/live/sequences.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ export const handleMessage = [
127127
true: [],
128128
false: [
129129
actions.consumeModule,
130+
actions.setReceivingStatus,
130131
set(props`shortid`, props`moduleShortid`),
131132
set(props`code`, props`module.code`),
132133
changeCode,
133134
setModuleSaved,
135+
actions.unSetReceivingStatus,
134136
],
135137
},
136138
],

packages/common/sandbox/modules.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ export const getModulePath = (
153153

154154
let directory = findByShortid(directories, module.directoryShortid);
155155
let path = '/';
156+
157+
if (directory == null && module.directoryShortid) {
158+
// Parent got deleted, return '';
159+
160+
return '';
161+
}
162+
156163
while (directory != null) {
157164
path = `/${directory.title}${path}`;
158165
const lastDirectoryShortid = directory.directoryShortid;

0 commit comments

Comments
 (0)