Skip to content

Commit d30319a

Browse files
fix live updates
1 parent e543dc7 commit d30319a

File tree

3 files changed

+3
-59
lines changed

3 files changed

+3
-59
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export type OnFileChangeData = {
3030
moduleShortid: string;
3131
title: string;
3232
code: string;
33-
event?: any[];
34-
model?: any;
33+
model: any;
3534
};
3635

3736
export type OnOperationAppliedData = {
@@ -446,7 +445,6 @@ export class ModelsHandler {
446445
moduleShortid: module.shortid,
447446
title: module.title,
448447
code: model.getValue(),
449-
event: e,
450448
model,
451449
});
452450
} catch (err) {

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -188,32 +188,9 @@ export const onOperationApplied: Action<{
188188
export const codeChanged: Action<{
189189
moduleShortid: string;
190190
code: string;
191-
event?: any;
192-
}> = ({ effects, state, actions }, { code, moduleShortid, event }) => {
191+
}> = ({ effects, state, actions }, { code, moduleShortid }) => {
193192
effects.analytics.trackOnce('Change Code');
194193

195-
if (
196-
state.live.isLive &&
197-
moduleShortid === state.editor.currentModuleShortid &&
198-
event &&
199-
event.changes
200-
) {
201-
try {
202-
actions.live.onTransformMade({
203-
moduleShortid,
204-
event,
205-
code: state.editor.currentModule.code,
206-
});
207-
} catch (e) {
208-
// Something went wrong while composing the operation, so we're opting for a full sync
209-
console.error(e);
210-
211-
if (this.props.onModuleStateMismatch) {
212-
this.props.onModuleStateMismatch();
213-
}
214-
}
215-
}
216-
217194
const module = state.editor.currentSandbox.modules.find(
218195
m => m.shortid === moduleShortid
219196
);
@@ -223,9 +200,7 @@ export const codeChanged: Action<{
223200
}
224201

225202
if (state.live.isLive) {
226-
state.live.receivingCode = true;
227-
effects.live.sendCodeUpdate(moduleShortid, module.code || '', code);
228-
state.live.receivingCode = false;
203+
effects.live.sendCodeUpdate(moduleShortid, module.code, code);
229204
}
230205

231206
actions.editor.internal.setModuleCode({

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Action, AsyncAction, Operator } from 'app/overmind';
33
import { withLoadApp } from 'app/overmind/factories';
44
import { filter, fork, pipe } from 'overmind';
55

6-
import eventToTransform from '../../utils/event-to-transform';
76
import * as internalActions from './internalActions';
87
import * as liveMessage from './liveMessageOperators';
98

@@ -68,34 +67,6 @@ export const liveMessageReceived: Operator<LiveMessage> = pipe(
6867
})
6968
);
7069

71-
export const onTransformMade: Action<{
72-
event: any;
73-
moduleShortid: string;
74-
code: string;
75-
}> = ({ effects, state }, { event, moduleShortid, code }) => {
76-
if (!state.live.isCurrentEditor) {
77-
return;
78-
}
79-
80-
const { operation } = eventToTransform(event, code);
81-
82-
if (!operation) {
83-
return;
84-
}
85-
86-
try {
87-
effects.live.applyClient(moduleShortid, operation.toJSON());
88-
} catch (e) {
89-
// Something went wrong, probably a sync mismatch. Request new version
90-
console.error(
91-
'Something went wrong with applying OT operation',
92-
moduleShortid,
93-
operation
94-
);
95-
effects.live.sendModuleState();
96-
}
97-
};
98-
9970
export const applyTransformation: Action<{
10071
operation: any;
10172
moduleShortid: string;

0 commit comments

Comments
 (0)