diff --git a/web/view_history.js b/web/view_history.js index d4f65f2bc..a05482102 100644 --- a/web/view_history.js +++ b/web/view_history.js @@ -18,7 +18,7 @@ 'use strict'; -var VIEW_HISTORY_MEMORY = 20; +var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; /** * View History - This is a utility for saving various view parameters for @@ -30,8 +30,9 @@ var VIEW_HISTORY_MEMORY = 20; * - GENERIC or CHROME - uses localStorage, if it is available. */ var ViewHistory = (function ViewHistoryClosure() { - function ViewHistory(fingerprint) { + function ViewHistory(fingerprint, cacheSize) { this.fingerprint = fingerprint; + this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE; this.isInitializedPromiseResolved = false; this.initializedPromise = this._readFromStorage().then(function (databaseStr) { @@ -41,7 +42,7 @@ var ViewHistory = (function ViewHistoryClosure() { if (!('files' in database)) { database.files = []; } - if (database.files.length >= VIEW_HISTORY_MEMORY) { + if (database.files.length >= this.cacheSize) { database.files.shift(); } var index;