reworked history length handling...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-09-19 15:54:21 +03:00
parent ab0e429189
commit a5aec38bcb

View File

@ -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 { // we will not remove pinned items...
var k = Object.keys(this.url_history) .filter(function(e){
// we will not remove pinned items... return that.url_history[e].pinned == null })
.filter((function(e){ // we clear the head of the list -- first/oldest urls added...
return this.url_history[e].pinned != null }).bind(this)) to_remove.reverse()
// do the actual removal...
// drop first url in order -- first added... to_remove
k.length > l .slice(l)
&& this.dropURLFromHistory(k[0]) .forEach(function(e){
} while(k.length - 1 > l) 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.