mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 20:00:10 +00:00
added history pruning -- removal of non-existant paths, not sure if this strategy is good enough...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c0168762ea
commit
3c7e772203
@ -58,7 +58,6 @@ if(window.CEF_dumpJSON != null){
|
||||
// paths to included utils...
|
||||
execPathPush('./vips/bin')
|
||||
|
||||
|
||||
// Things ImageGrid needs...
|
||||
// XXX do we need assync versions??
|
||||
window.listDir = function(path){
|
||||
|
||||
@ -18,6 +18,18 @@ var BASE_URL_LIMIT = 10
|
||||
* URL history...
|
||||
*/
|
||||
|
||||
// XXX this depends on fs.existsSync(...)
|
||||
function pruneBaseURLHistory(){
|
||||
if(window.fs == null){
|
||||
return BASE_URL_HISTORY
|
||||
}
|
||||
BASE_URL_HISTORY = BASE_URL_HISTORY.filter(function(e){
|
||||
return fs.existsSync(osPath(e))
|
||||
})
|
||||
return BASE_URL_HISTORY
|
||||
}
|
||||
|
||||
|
||||
// Setup history event handlers...
|
||||
//
|
||||
// NOTE: this will save history state to localStorage...
|
||||
@ -26,6 +38,8 @@ function setupBaseURLHistory(){
|
||||
.on('baseURLChanged', function(evt, old_url, new_url){
|
||||
var updated = false
|
||||
|
||||
pruneBaseURLHistory()
|
||||
|
||||
// store the old and new urls in history unless they already
|
||||
// exist...
|
||||
if(BASE_URL_HISTORY.indexOf(old_url) < 0){
|
||||
@ -102,6 +116,7 @@ function getURLHistoryPrev(){
|
||||
// NOTE: this will not affect history url order...
|
||||
function makeURLHistoryLoader(get, end_msg){
|
||||
return function(){
|
||||
pruneBaseURLHistory()
|
||||
var url = get()
|
||||
if(url != BASE_URL){
|
||||
statusNotify(loadDir(url))
|
||||
@ -118,7 +133,8 @@ var loadURLHistoryPrev = makeURLHistoryLoader(getURLHistoryPrev, 'at first URL')
|
||||
// NOTE: this can accept either path or history index...
|
||||
// NOTE: this will not reload an already loaded url...
|
||||
function loadURLHistoryAt(a){
|
||||
a = a < 0 ? BASE_URL_HISTORY + a : a
|
||||
pruneBaseURLHistory()
|
||||
a = a < 0 ? BASE_URL_HISTORY.length + a : a
|
||||
var url = typeof(a) == typeof(123) ? Math.min(a < 0 ? 0 : a, BASE_URL_HISTORY.length-1) : a
|
||||
if(url != BASE_URL){
|
||||
statusNotify(loadDir(url))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user