Browse Source

Wait for the counter update during the load. Fixes #5385

pull/5399/head
Artur Arseniev 2 years ago
parent
commit
0c01cf69b8
  1. 4
      src/editor/model/Editor.ts
  2. 2
      src/utils/mixins.ts

4
src/editor/model/Editor.ts

@ -2,7 +2,7 @@ import { isUndefined, isArray, contains, toArray, keys, bindAll } from 'undersco
import Backbone from 'backbone'; import Backbone from 'backbone';
import $ from '../../utils/cash-dom'; import $ from '../../utils/cash-dom';
import Extender from '../../utils/extender'; import Extender from '../../utils/extender';
import { getModel, hasWin, isEmptyObj } from '../../utils/mixins'; import { getModel, hasWin, isEmptyObj, wait } from '../../utils/mixins';
import { AddOptions, Model } from '../../common'; import { AddOptions, Model } from '../../common';
import Selected from './Selected'; import Selected from './Selected';
import FrameView from '../../canvas/view/FrameView'; import FrameView from '../../canvas/view/FrameView';
@ -835,6 +835,8 @@ export default class EditorModel extends Model {
async load(options?: any) { async load(options?: any) {
const result = await this.Storage.load(options); const result = await this.Storage.load(options);
this.loadData(result); this.loadData(result);
// Wait in order to properly update the dirty counter (#5385)
await wait();
return result; return result;
} }

2
src/utils/mixins.ts

@ -5,6 +5,8 @@ import { isTextNode } from './dom';
import Component from '../dom_components/model/Component'; import Component from '../dom_components/model/Component';
import { ObjectAny } from '../common'; import { ObjectAny } from '../common';
export const wait = (mls: number = 0) => new Promise(res => setTimeout(res, mls));
export const isDef = (value: any) => typeof value !== 'undefined'; export const isDef = (value: any) => typeof value !== 'undefined';
export const hasWin = () => typeof window !== 'undefined'; export const hasWin = () => typeof window !== 'undefined';

Loading…
Cancel
Save