From 222bb5bad4d2b422d8f4791ee31e87492d5b01ee Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 6 Apr 2018 04:27:58 -0400 Subject: [PATCH] Target selector: Don't lose recent targets when saving to same target A target could fill up the list from different sessions, pushing other recents out. --- chrome/content/zotero/xpcom/server_connector.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index 87a07ad54..763028804 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -263,10 +263,13 @@ Zotero.Server.Connector.SaveSession.prototype._updateRecents = function () { } // Otherwise add this target to the end if (!sessionFound) { - recents.push({ - id: targetID, - sessionID: this.id - }); + recents + // Remove this target from the list if it's there from another session + .filter(r => r.id != targetID) + .concat({ + id: targetID, + sessionID: this.id + }); } recents = recents.slice(-1 * numRecents); Zotero.Prefs.set('recentSaveTargets', JSON.stringify(recents));