Skip to content

Commit 47f9a6d

Browse files
committed
Use updatedModule.code for getting the latest version
1 parent f343089 commit 47f9a6d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/@types/ot/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ declare module 'ot' {
22
export type SerializedTextOperation = (string | number)[];
33

44
class TextOperation {
5+
ops: SerializedTextOperation;
6+
57
delete(length: number): TextOperation;
68
insert(str: string): TextOperation;
79
retain(length: number): TextOperation;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,14 @@ class Live {
393393
return;
394394
}
395395

396+
if (operation.ops.length === 1) {
397+
const [op] = operation.ops;
398+
if (typeof op === 'number') {
399+
// Useless to send a single retain operation, ignore
400+
return;
401+
}
402+
}
403+
396404
if (moduleShortid.startsWith(OPTIMISTIC_ID_PREFIX)) {
397405
// Module is an optimistic module, we will send a full code update
398406
// once the module has been created, until then, send nothing!

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ export const moduleCreated: AsyncAction<{
691691
actions.editor.internal.setCurrentModule(module);
692692

693693
try {
694-
const savedCode = module.code;
695694
const updatedModule = await effects.api.createModule(sandbox.id, module);
696695

697696
module.id = updatedModule.id;
@@ -710,7 +709,7 @@ export const moduleCreated: AsyncAction<{
710709
// Update server with latest data
711710
effects.live.sendCodeUpdate(
712711
module.shortid,
713-
getTextOperation(savedCode || '', module.code)
712+
getTextOperation(updatedModule.code || '', module.code)
714713
);
715714
}
716715
} catch (error) {

0 commit comments

Comments
 (0)