mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9415271d2b
commit
bfd7f1ad70
@ -1112,18 +1112,48 @@ module.Tags = core.ImageGridFeatures.Feature({
|
|||||||
this.markChanged('images', gids)
|
this.markChanged('images', gids)
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX
|
// store .tags and .tags.selected / .tags.bookmark separately from .data...
|
||||||
|
//
|
||||||
|
// XXX see if this can be automated...
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res, _, full){
|
function(res, _, full){
|
||||||
// XXX move code here from file.buildIndex(..)
|
var changes = this.changes
|
||||||
// - res.raw.tags -> res.index.tags
|
|
||||||
// - ..tags.selected -> .selected
|
if((full || changes == null || changes.tags) && res.raw.data.tags){
|
||||||
// - ..tags.bookmark -> .bookmarked
|
res.index.tags = res.raw.data.tags
|
||||||
// XXX will need a symmetrical action to reverse all of this...
|
}
|
||||||
|
|
||||||
|
if((full || changes == null || changes.selected)
|
||||||
|
&& res.raw.data.tags
|
||||||
|
&& res.raw.data.tags.selected){
|
||||||
|
res.index.marked = res.raw.data.tags.selected
|
||||||
|
}
|
||||||
|
if((full || changes == null || changes.bookmarked)
|
||||||
|
&& res.raw.data.tags
|
||||||
|
&& res.raw.data.tags.bookmark){
|
||||||
|
res.index.bookmarked = [
|
||||||
|
res.raw.data.tags.bookmark || [],
|
||||||
|
{},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup...
|
||||||
|
if(res.index.data && res.index.data.tags){
|
||||||
|
delete res.index.data.tags.selected
|
||||||
|
delete res.index.data.tags.bookmark
|
||||||
|
//delete res.index.data.tags.bookmark_data
|
||||||
|
delete res.index.data.tags
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
['prepareJSONForLoad',
|
['prepareJSONForLoad',
|
||||||
function(res){
|
function(res, json){
|
||||||
// XXX
|
res.data.tags = json.tags || {}
|
||||||
|
|
||||||
|
res.data.tags.selected = json.marked || []
|
||||||
|
res.data.tags.bookmark = json.bookmarked ? json.bookmarked[0] : []
|
||||||
|
//res.data.tags.bookmark_data = json.bookmarked ? json.bookmarked[1] : {}
|
||||||
|
|
||||||
|
res.data.sortTags()
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -795,13 +795,6 @@ module.buildIndex = function(index, base_path){
|
|||||||
// buildup the data object...
|
// buildup the data object...
|
||||||
// NOTE: this is mostly to attach stuff that is stored in separate files...
|
// NOTE: this is mostly to attach stuff that is stored in separate files...
|
||||||
|
|
||||||
// XXX move this to tags/marks/bookmarks...
|
|
||||||
// .tags + bookmarks + selection...
|
|
||||||
d.tags = index.tags || {}
|
|
||||||
d.tags.bookmark = index.bookmarked ? index.bookmarked[0] : []
|
|
||||||
d.tags.selected = index.marked || []
|
|
||||||
d.sortTags()
|
|
||||||
|
|
||||||
// .current...
|
// .current...
|
||||||
d.current = index.current || d.current
|
d.current = index.current || d.current
|
||||||
|
|
||||||
@ -909,37 +902,6 @@ function(json, changes){
|
|||||||
res.data = json.data
|
res.data = json.data
|
||||||
}
|
}
|
||||||
|
|
||||||
// tags...
|
|
||||||
if((changes === true || changes) && json.data.tags != null){
|
|
||||||
// NOTE: we write the whole set ONLY if an item is true or undefined
|
|
||||||
// i.e. not false...
|
|
||||||
if(changes === true || changes.bookmarked){
|
|
||||||
res.bookmarked = [
|
|
||||||
json.data.tags.bookmark || [],
|
|
||||||
// NOTE: this is for bookmark metadata line comments, text,
|
|
||||||
// tags, ... etc.
|
|
||||||
// XXX currently this is not used...
|
|
||||||
json.data.bookmark_data || {},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
if(changes === true || changes.selected){
|
|
||||||
res.marked = json.data.tags.selected || []
|
|
||||||
}
|
|
||||||
|
|
||||||
if(changes === true || changes.tags){
|
|
||||||
res.tags = json.data.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean out some stuff from data...
|
|
||||||
if(res.data){
|
|
||||||
delete res.data.tags.bookmark
|
|
||||||
delete res.data.tags.bookmark_data
|
|
||||||
delete res.data.tags.selected
|
|
||||||
delete res.data.tags
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(changes === true || changes && changes.images === true){
|
if(changes === true || changes && changes.images === true){
|
||||||
res.images = json.images
|
res.images = json.images
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user