From ac20bb957efe752dee08ecacd7e96444f17382cd Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 1 Sep 2018 18:09:29 +0300 Subject: [PATCH] fixed a bug in truncating url history -- now pinned items should never be implicitly removed... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/history.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js index 92afe6d4..805c1a9a 100755 --- a/ui (gen4)/features/history.js +++ b/ui (gen4)/features/history.js @@ -55,6 +55,18 @@ var URLHistoryActions = actions.Actions({ set url_history(value){ this.__url_history = value }, + // NOTE: this is created on the fly as a convenience, editing this + // will have no effect... + get url_history_pinned(){ + var url_history = this.url_history + return Object.keys(url_history) + .reduce(function(res, k){ + if(url_history[k].pinned){ + res[k] = url_history[k] + } + return res + }, {}) }, + clone: [function(full){ return function(res){ @@ -145,15 +157,15 @@ var URLHistoryActions = actions.Actions({ // update history length... if(l > 0){ - var k = Object.keys(this.url_history) - // we will not remove pinned items... - .filter((function(e){ - return !this.url_history[e].pinned }).bind(this)) - while(k.length > l){ - // drop first url in order -- last added... - this.dropURLFromHistory(k[0]) + do { var k = Object.keys(this.url_history) - } + // we will not remove pinned items... + .filter((function(e){ + return !this.url_history[e].pinned }).bind(this)) + + // drop first url in order -- first added... + this.dropURLFromHistory(k[0]) + } while(k.length - 1 > l) } }], // NOTE: url can be an index, 0 being the last url added to history;