mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactoring, notes and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ec748636f2
commit
627f971e22
@ -1155,43 +1155,46 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// XXX save metadata only if changed... (???)
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res){
|
function(res){
|
||||||
if(!res.changes){
|
if(!res.changes){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var that = this
|
var that = this
|
||||||
var changed = res.changes === true
|
var changes = res.changes
|
||||||
|| res.changes.collections
|
|
||||||
var collections = this.collections
|
var collections = this.collections
|
||||||
|
|
||||||
// collections partially changed...
|
// collections fully/partially changed...
|
||||||
var partial = Object.keys(collections || {})
|
var full = changes === true ? true
|
||||||
.filter(function(t){
|
: Object.keys(collections || {})
|
||||||
return res.changes['collection: '
|
.filter(function(t){
|
||||||
+ JSON.stringify(collections[t].gid)] })
|
return res.changes['collection: '
|
||||||
|
+ JSON.stringify(collections[t].gid)] === true })
|
||||||
|
var partial = changes === true ? []
|
||||||
|
: Object.keys(collections || {})
|
||||||
|
.filter(function(t){
|
||||||
|
return full.indexOf(t) < 0
|
||||||
|
&& res.changes['collection: '
|
||||||
|
+ JSON.stringify(collections[t].gid)] })
|
||||||
|
|
||||||
if((partial.length > 0 || changed)
|
if((full.length > 0 || partial.length > 0)
|
||||||
&& res.raw.collections){
|
&& res.raw.collections){
|
||||||
// select the actual changed collection list...
|
// select the actual changed collection list...
|
||||||
changed = changed === true ?
|
changed = changes === true ?
|
||||||
Object.keys(res.raw.collections)
|
Object.keys(res.raw.collections)
|
||||||
: changed
|
: (full).concat(partial)
|
||||||
changed = (changed || []).concat(partial)
|
|
||||||
|
|
||||||
// collection index...
|
// collection index...
|
||||||
//
|
|
||||||
// NOTE: we are placing this in the index root to
|
// NOTE: we are placing this in the index root to
|
||||||
// simplify lazy-loading of the collection
|
// simplify lazy-loading of the collection
|
||||||
// index...
|
// index...
|
||||||
// XXX save this only if index has changed...
|
if(changes && changes.collections){
|
||||||
// ...need 'collection-index' in changes...
|
var index = res.index['collection-index'] = {}
|
||||||
// XXX need lazy-load handler in fs-loader for this...
|
Object.keys(res.raw.collections)
|
||||||
// XXX don't like the name...
|
.forEach(function(title){
|
||||||
var index = res.index['collection-index'] = {}
|
index[collections[title].gid || title] = title })
|
||||||
Object.keys(res.raw.collections)
|
}
|
||||||
.forEach(function(title){
|
|
||||||
index[collections[title].gid || title] = title })
|
|
||||||
|
|
||||||
var change_tags = this.config['collection-transfer-changes'] || ['data']
|
var change_tags = this.config['collection-transfer-changes'] || ['data']
|
||||||
|
|
||||||
@ -1202,29 +1205,24 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
&& changed.indexOf(k) >= 0 })
|
&& changed.indexOf(k) >= 0 })
|
||||||
.forEach(function(k){
|
.forEach(function(k){
|
||||||
var gid = res.raw.collections[k].gid || k
|
var gid = res.raw.collections[k].gid || k
|
||||||
|
var id = 'collection: '+ JSON.stringify(gid)
|
||||||
var path = 'collections/'+ gid
|
var path = 'collections/'+ gid
|
||||||
var raw = res.raw.collections[k]
|
var raw = res.raw.collections[k]
|
||||||
|
|
||||||
// local collection changes...
|
// local collection changes...
|
||||||
// XXX local changes are not processed correctly
|
|
||||||
// when the target collection is loaded...
|
|
||||||
// XXX revise the local changes format...
|
|
||||||
var local_changes = partial.indexOf(k) < 0 || {}
|
var local_changes = partial.indexOf(k) < 0 || {}
|
||||||
if(local_changes !== true){
|
if(local_changes !== true && res.changes[id] !== true){
|
||||||
(res.changes['collection: '+ JSON.stringify(gid)] || [])
|
(res.changes[id] || [])
|
||||||
.forEach(function(c){ local_changes[c] = true })
|
.forEach(function(c){ local_changes[c] = true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// collections/<gid>/metadata
|
// collections/<gid>/metadata
|
||||||
|
// XXX save this only if changed... (???)
|
||||||
var metadata = res.index[path +'/metadata'] = {}
|
var metadata = res.index[path +'/metadata'] = {}
|
||||||
Object.keys(raw)
|
Object.keys(raw)
|
||||||
.forEach(function(key){ metadata[key] = raw[key] })
|
.forEach(function(key){ metadata[key] = raw[key] })
|
||||||
|
|
||||||
raw.date = res.date
|
raw.date = res.date
|
||||||
// XXX use collection changes!!!
|
|
||||||
// ...this will need .prepareIndexForWrite(..)
|
|
||||||
// refactoring to replace 'full' with 'changed'...
|
|
||||||
//var prepared = that.prepareIndexForWrite(raw, true).index
|
|
||||||
var prepared = that.prepareIndexForWrite(raw, local_changes).index
|
var prepared = that.prepareIndexForWrite(raw, local_changes).index
|
||||||
|
|
||||||
// move the collection data to collection path...
|
// move the collection data to collection path...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user