Browse Source

[#6587]: Fix infinite text nodes on dragging into a symbol (#6600)

* [#6587]: Fix infinite text nodes on dragging into a symbol

* Fix race condition during storing project data

* Update bug fix
pull/6604/head
mohamed yahia 5 months ago
committed by GitHub
parent
commit
3b97b7a043
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 13
      packages/core/src/editor/model/Editor.ts

13
packages/core/src/editor/model/Editor.ts

@ -119,6 +119,7 @@ export default class EditorModel extends Model {
destroyed = false;
_config: InitEditorConfig;
_storageTimeout?: ReturnType<typeof setTimeout>;
_isStoring: boolean = false;
attrsOrig: any;
timedInterval?: ReturnType<typeof setTimeout>;
updateItr?: ReturnType<typeof setTimeout>;
@ -869,9 +870,19 @@ export default class EditorModel extends Model {
* @public
*/
async store<T extends StorageOptions>(options?: T) {
if (this._isStoring) return;
this._isStoring = true;
// We use a 1ms timeout to defer the cleanup to the next tick of the event loop.
// This prevents a race condition where a store operation, like 'sync:content',
// might increase the dirty count before it can be properly cleared.
setTimeout(() => {
this.clearDirtyCount();
}, 1);
const data = this.storeData();
await this.Storage.store(data, options);
this.clearDirtyCount();
setTimeout(() => {
this._isStoring = false;
}, 1);
return data;
}

Loading…
Cancel
Save