|
@@ -115,12 +115,12 @@ export default class Autosave extends Plugin {
|
|
|
const pendingActions = editor.plugins.get( PendingActions );
|
|
const pendingActions = editor.plugins.get( PendingActions );
|
|
|
|
|
|
|
|
this.listenTo( doc, 'change:data', () => {
|
|
this.listenTo( doc, 'change:data', () => {
|
|
|
- this._addAction();
|
|
|
|
|
|
|
+ this._incrementCounter();
|
|
|
|
|
|
|
|
const willOriginalFunctionBeCalled = this._throttledSave();
|
|
const willOriginalFunctionBeCalled = this._throttledSave();
|
|
|
|
|
|
|
|
if ( !willOriginalFunctionBeCalled ) {
|
|
if ( !willOriginalFunctionBeCalled ) {
|
|
|
- this._removeAction();
|
|
|
|
|
|
|
+ this._decrementCounter();
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -171,7 +171,7 @@ export default class Autosave extends Plugin {
|
|
|
// Marker's change may not produce an operation, so the document's version
|
|
// Marker's change may not produce an operation, so the document's version
|
|
|
// can be the same after that change.
|
|
// can be the same after that change.
|
|
|
if ( !this.provider || version < this._lastDocumentVersion ) {
|
|
if ( !this.provider || version < this._lastDocumentVersion ) {
|
|
|
- this._removeAction();
|
|
|
|
|
|
|
+ this._decrementCounter();
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -180,14 +180,14 @@ export default class Autosave extends Plugin {
|
|
|
|
|
|
|
|
Promise.resolve( this.provider.save() )
|
|
Promise.resolve( this.provider.save() )
|
|
|
.then( () => {
|
|
.then( () => {
|
|
|
- this._removeAction();
|
|
|
|
|
|
|
+ this._decrementCounter();
|
|
|
} );
|
|
} );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @private
|
|
* @private
|
|
|
*/
|
|
*/
|
|
|
- _addAction() {
|
|
|
|
|
|
|
+ _incrementCounter() {
|
|
|
this._saveActionCounter++;
|
|
this._saveActionCounter++;
|
|
|
|
|
|
|
|
if ( !this._action ) {
|
|
if ( !this._action ) {
|
|
@@ -199,7 +199,7 @@ export default class Autosave extends Plugin {
|
|
|
/**
|
|
/**
|
|
|
* @private
|
|
* @private
|
|
|
*/
|
|
*/
|
|
|
- _removeAction() {
|
|
|
|
|
|
|
+ _decrementCounter() {
|
|
|
this._saveActionCounter--;
|
|
this._saveActionCounter--;
|
|
|
|
|
|
|
|
if ( this._saveActionCounter === 0 ) {
|
|
if ( this._saveActionCounter === 0 ) {
|