mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
reworked history length handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ab0e429189
commit
a5aec38bcb
@ -130,6 +130,7 @@ var URLHistoryActions = actions.Actions({
|
|||||||
// history is more than allowed...
|
// history is more than allowed...
|
||||||
pushURLToHistory: ['- History/',
|
pushURLToHistory: ['- History/',
|
||||||
function(url, open, check, clear){
|
function(url, open, check, clear){
|
||||||
|
var that = this
|
||||||
url = url || this.location.path
|
url = url || this.location.path
|
||||||
var l = this.config['url-history-length'] || -1
|
var l = this.config['url-history-length'] || -1
|
||||||
|
|
||||||
@ -156,18 +157,18 @@ var URLHistoryActions = actions.Actions({
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// update history length...
|
// update history length...
|
||||||
if(l > 0){
|
var to_remove = Object.keys(this.url_history)
|
||||||
do {
|
|
||||||
var k = Object.keys(this.url_history)
|
|
||||||
// we will not remove pinned items...
|
// we will not remove pinned items...
|
||||||
.filter((function(e){
|
.filter(function(e){
|
||||||
return this.url_history[e].pinned != null }).bind(this))
|
return that.url_history[e].pinned == null })
|
||||||
|
// we clear the head of the list -- first/oldest urls added...
|
||||||
// drop first url in order -- first added...
|
to_remove.reverse()
|
||||||
k.length > l
|
// do the actual removal...
|
||||||
&& this.dropURLFromHistory(k[0])
|
to_remove
|
||||||
} while(k.length - 1 > l)
|
.slice(l)
|
||||||
}
|
.forEach(function(e){
|
||||||
|
console.log('Removing url from history:', e)
|
||||||
|
that.dropURLFromHistory(e) })
|
||||||
}],
|
}],
|
||||||
// NOTE: url can be an index, 0 being the last url added to history;
|
// NOTE: url can be an index, 0 being the last url added to history;
|
||||||
// negative values are also supported.
|
// negative values are also supported.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user