Skip to content

Commit

Permalink
Fix storage loading
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jun 30, 2017
1 parent 1d6a0ab commit 63e0fd0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ <h1 class="bdg-title">The team</h1>
clearOnRender: 0,

storageManager:{
autoload: 0,
autoload: 1,
storeComponents: 1,
storeStyles: 1,
},
Expand Down Expand Up @@ -1173,6 +1173,16 @@ <h1 class="bdg-title">The team</h1>
},
});

/*
// Store and load events
editor.on('storage:load', function(e) {
console.log('LOAD ', e);
})
editor.on('storage:store', function(e) {
console.log('STORE ', e);
})
*/

editor.render();
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions src/dom_components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ module.exports = () => {
}catch(err){}
}else if(d.html)
obj = d.html;

if (obj) {
this.clear();
this.getComponents().reset(obj);
this.getComponents().reset();
this.getComponents().add(obj);
}

return obj;
Expand Down
27 changes: 15 additions & 12 deletions src/editor/model/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,21 @@ module.exports = Backbone.Model.extend({
* @private
* */
componentsUpdated(model, val, opt) {
var count = this.get('changesCount') + 1;
var avoidStore = opt ? opt.avoidStore : 0;
var stm = this.get('StorageManager');
this.set('changesCount', count);

if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) {
return;
}

if (!avoidStore) {
this.store();
}
timedInterval && clearInterval(timedInterval);
timedInterval = setTimeout(() => {
var count = this.get('changesCount') + 1;
var avoidStore = opt ? opt.avoidStore : 0;
var stm = this.get('StorageManager');
this.set('changesCount', count);

if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) {
return;
}

if (!avoidStore) {
this.store();
}
}, 0);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/editor/view/EditorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = Backbone.View.extend({
dComps.clear();
}
dComps.getComponents().reset(config.components);
um.clear();
model.loadOnStart();
um.clear();
// This will init loaded components
dComps.onLoad();
}
Expand Down

0 comments on commit 63e0fd0

Please sign in to comment.