Skip to content

Commit

Permalink
Add more debug logs for undo feature (#149)
Browse files Browse the repository at this point in the history
* Use optional chaining (?.) for conditional call

* Add more debug logs for undo feature

Co-authored-by: Matías Surdi <matias.emanuel.surdi@automattic.om>
  • Loading branch information
msurdi and Matías Surdi authored May 25, 2022
1 parent fc3f2c2 commit 8d9c154
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/collaborative-editing/use-yjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async function initYDoc( { settings, registry } ) {

doc.onConnectionReady(
once( () => {
debug( 'Connection ready. Setting up ydoc document and undo manager' );
dispatch( 'isolated/editor' ).setYDoc( doc );
setupUndoManager( doc.getPostMap(), identity, registry );
} )
Expand Down
2 changes: 2 additions & 0 deletions src/store/collab/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export default {
const undoManager = registry.select( 'isolated/editor' ).getUndoManager();

if ( ! undoManager ) {
debugUndo( 'Undoing from redux-undo state' );
return action;
}
debugUndo( 'Undoing from yjs undoManager' );

debugUndo( 'undo' );
undoManager.undo();
Expand Down

0 comments on commit 8d9c154

Please sign in to comment.