mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
started tuning the order saving and caching...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9eaad5e6e8
commit
f204503464
@ -899,7 +899,7 @@ module.Base = core.ImageGridFeatures.Feature({
|
|||||||
'flipHorizontal',
|
'flipHorizontal',
|
||||||
'flipVertical',
|
'flipVertical',
|
||||||
],
|
],
|
||||||
function(_, target){ this.markChanged('images', [that.data.getImage(target)]) }],
|
function(_, target){ this.markChanged('images', [this.data.getImage(target)]) }],
|
||||||
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -858,9 +858,11 @@ var ChangesActions = actions.Actions({
|
|||||||
Mark item(s) of section as changed...
|
Mark item(s) of section as changed...
|
||||||
.markChanged(<section>, [<item>, .. ])
|
.markChanged(<section>, [<item>, .. ])
|
||||||
|
|
||||||
|
NOTE: when marking section items, the new items will be added to
|
||||||
|
the set of already marked items.
|
||||||
NOTE: when .changes is null (i.e. everything changed, marked via
|
NOTE: when .changes is null (i.e. everything changed, marked via
|
||||||
.markChanged('all')) then calling this with anything other
|
.markChanged('all')) then calling this with anything other
|
||||||
than 'none' will have no effect.
|
than 'none' will have no effect.
|
||||||
`,
|
`,
|
||||||
function(section, items){
|
function(section, items){
|
||||||
var that = this
|
var that = this
|
||||||
@ -894,7 +896,7 @@ var ChangesActions = actions.Actions({
|
|||||||
|
|
||||||
// section items...
|
// section items...
|
||||||
} else if(items instanceof Array) {
|
} else if(items instanceof Array) {
|
||||||
changes[section] = (changes[section] || []).concat(items)
|
changes[section] = (changes[section] || []).concat(items).unique()
|
||||||
this.changes = changes
|
this.changes = changes
|
||||||
|
|
||||||
// section(s)...
|
// section(s)...
|
||||||
|
|||||||
@ -469,21 +469,34 @@ module.Sort = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res){
|
function(res){
|
||||||
var changed = this.changes == null
|
var c = this.changes
|
||||||
|| this.changes.sort_cache
|
|
||||||
|
|
||||||
if(changed && res.raw.sort_order){
|
var save = function(attr){
|
||||||
res.index['sort_order'] = res.raw.sort_order
|
if((c == null || c[attr]) && res.raw[attr]){
|
||||||
}
|
// full save...
|
||||||
if(changed && res.raw.sort_cache){
|
if(c == null){
|
||||||
res.index['sort_cache'] = res.raw.sort_cache
|
res.index[attr] = res.raw[attr]
|
||||||
|
|
||||||
|
// build diff...
|
||||||
|
} else {
|
||||||
|
var diff = {}
|
||||||
|
c[attr].forEach(function(k){ diff[k] = res.raw[attr][k] })
|
||||||
|
res.index[attr +'-diff'] = diff
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save('sort_order')
|
||||||
|
save('sort_cache')
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// manage changes...
|
// manage changes...
|
||||||
// XXX also need to mark 'sort_cache'
|
|
||||||
['sortImages',
|
['sortImages',
|
||||||
function(_, target){ this.markChanged('data') }],
|
function(_, target){ this.markChanged('data') }],
|
||||||
|
['saveOrder',
|
||||||
|
function(_, title){ this.markChanged('sort_order', [title]) }],
|
||||||
|
['cacheOrder',
|
||||||
|
function(){ this.markChanged('sort_cache', [this.data.sort_method]) }],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user