From a5aec38bcb7c2d36bc281277249dcd89bff6406d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 19 Sep 2018 15:54:21 +0300 Subject: [PATCH] reworked history length handling... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/history.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js index 22ca1b87..5dd2c610 100755 --- a/ui (gen4)/features/history.js +++ b/ui (gen4)/features/history.js @@ -130,6 +130,7 @@ var URLHistoryActions = actions.Actions({ // history is more than allowed... pushURLToHistory: ['- History/', function(url, open, check, clear){ + var that = this url = url || this.location.path var l = this.config['url-history-length'] || -1 @@ -156,18 +157,18 @@ var URLHistoryActions = actions.Actions({ }*/ // update history length... - if(l > 0){ - do { - var k = Object.keys(this.url_history) - // we will not remove pinned items... - .filter((function(e){ - return this.url_history[e].pinned != null }).bind(this)) - - // drop first url in order -- first added... - k.length > l - && this.dropURLFromHistory(k[0]) - } while(k.length - 1 > l) - } + var to_remove = Object.keys(this.url_history) + // we will not remove pinned items... + .filter(function(e){ + return that.url_history[e].pinned == null }) + // we clear the head of the list -- first/oldest urls added... + to_remove.reverse() + // do the actual removal... + to_remove + .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; // negative values are also supported.