Skip to content

Commit

Permalink
Merge pull request #41 from Automattic/fix/collab-debounce
Browse files Browse the repository at this point in the history
Collab: Remove debounce
  • Loading branch information
mirka committed Aug 23, 2021
2 parents 572c438 + 6e26cd0 commit 110d5e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix handling of initial content from `onLoad` when collaborative editing is enabled
- Improved reliability of collaborative editing when multiple peers are typing simultaneously

## [2.3.0] - 2021-07-29

Expand Down
11 changes: 6 additions & 5 deletions src/components/block-editor-contents/use-yjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { v4 as uuidv4 } from 'uuid';
import { debounce, noop, sample } from 'lodash';
import { noop, sample } from 'lodash';
import { createDocument } from './yjs-doc';
import { postDocToObject, updatePostDoc } from './algorithms/yjs';

Expand All @@ -23,7 +23,6 @@ const debug = require( 'debug' )( 'iso-editor:collab' );
/** @typedef {import('../../..').EditorSelection} EditorSelection */
/** @typedef {import('..').OnUpdate} OnUpdate */

const DEBOUNCE_WAIT_MS = 800;
const defaultColors = [ '#4676C0', '#6F6EBE', '#9063B6', '#C3498D', '#9E6D14', '#3B4856', '#4A807A' ];

/**
Expand Down Expand Up @@ -182,11 +181,13 @@ export default function useYjs( { blocks, onRemoteDataChange, settings } ) {
disconnect();
};

applyChangesToYjs.current = debounce( ( blocks ) => {
applyChangesToYjs.current = ( blocks ) => {
if ( doc.getState() !== 'on' ) {
return;
}
debug( 'local changes applied to ydoc' );

doc.applyDataChanges( { blocks } );
}, DEBOUNCE_WAIT_MS );
};
} );

return () => onUnmount();
Expand Down
7 changes: 1 addition & 6 deletions src/components/formats/collab-caret/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mark.iso-editor-collab-caret.is-shifted::before {
mark.iso-editor-collab-caret::after {
position: absolute;
top: -14px;
left: -4px;
right: -4px;
overflow: hidden;
min-width: 8px;
max-width: 140px;
Expand All @@ -46,8 +46,3 @@ mark.iso-editor-collab-caret::after {
font-style: normal;
font-weight: normal;
}

mark.iso-editor-collab-caret.is-shifted::after {
left: auto;
right: -4px;
}

0 comments on commit 110d5e3

Please sign in to comment.