some refactoring + bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-02-23 03:28:44 +03:00
parent 98f0e129b5
commit f1a23fda6d
3 changed files with 13 additions and 13 deletions

View File

@ -979,16 +979,6 @@ module.Base = core.ImageGridFeatures.Feature({
img.forEach(function(_, img){ img.base_path = base_path })
}
// extra stuff...
// ...this will restore stuff stored in the data but not
// explicitly restored above...
// XXX do we need this???
Object.keys(json.data).forEach(function(k){
if(d[k] === undefined){
d[k] = json.data[k]
}
})
res.data = d
res.images = img
}],

View File

@ -2529,7 +2529,7 @@ var DataPrototype = {
//
// NOTE: this loads in-place, use .fromJSON(..) to create new data...
// XXX should this process defaults for unset values???
loadJSON: function(data){
loadJSON: function(data, clean){
var that = this
data = typeof(data) == typeof('str') ? JSON.parse(data) : data
data = formats.updateData(data)
@ -2550,6 +2550,15 @@ var DataPrototype = {
that[s][k] = that.makeSparseImages(data[s][k])
}
})
// extra data...
!clean
&& Object.keys(data).forEach(function(k){
if(k != 'version' && that[k] === undefined){
that[k] = data[k]
}
})
return this
},
@ -2559,7 +2568,7 @@ var DataPrototype = {
// the result...
dumpJSON: function(mode){
var res = {
varsion: module.DATA_VERSION,
version: module.DATA_VERSION,
base: this.base,
current: this.current,
order: this.order.slice(),

View File

@ -101,6 +101,7 @@ function(data){
// we set the base to the first ribbon...
res.base = data.base == null ? res.ribbon_order[0] : res.base
return res
}
@ -147,7 +148,7 @@ module.updateData = function(data, clean){
!clean
&& Object.keys(data).forEach(function(k){
if(res[k] == null){
if(res[k] === undefined){
res[k] = data[k]
}
})