www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0ac20d64a031fa40abdbbd3b122bb55dc169ca3d
parent 95a880991dcb03427dd8f733e49ede1909ace7af
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  5 Nov 2013 13:36:56 -0500

Cache Zotero.userID and Zotero.libraryID

Diffstat:
Mchrome/content/zotero/xpcom/zotero.js | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -90,25 +90,29 @@ Components.utils.import("resource://gre/modules/Services.jsm"); this.__defineGetter__('userID', function () { + if (_userID !== undefined) return _userID; var sql = "SELECT value FROM settings WHERE " + "setting='account' AND key='userID'"; - return Zotero.DB.valueQuery(sql); + return _userID = Zotero.DB.valueQuery(sql); }); this.__defineSetter__('userID', function (val) { var sql = "REPLACE INTO settings VALUES ('account', 'userID', ?)"; Zotero.DB.query(sql, parseInt(val)); + _userID = val; }); this.__defineGetter__('libraryID', function () { + if (_libraryID !== undefined) return _libraryID; var sql = "SELECT value FROM settings WHERE " + "setting='account' AND key='libraryID'"; - return Zotero.DB.valueQuery(sql); + return _libraryID = Zotero.DB.valueQuery(sql); }); this.__defineSetter__('libraryID', function (val) { var sql = "REPLACE INTO settings VALUES ('account', 'libraryID', ?)"; Zotero.DB.query(sql, parseInt(val)); + _libraryID = val; }); this.__defineGetter__('username', function () { @@ -173,6 +177,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); var _startupErrorHandler; var _zoteroDirectory = false; var _localizedStringBundle; + var _userID; + var _libraryID; var _localUserKey; var _waiting = 0;