diff --git a/chrome/content/zotero/advancedSearch.js b/chrome/content/zotero/advancedSearch.js index 7550f9e745..e614f771ab 100644 --- a/chrome/content/zotero/advancedSearch.js +++ b/chrome/content/zotero/advancedSearch.js @@ -28,7 +28,6 @@ var ZoteroAdvancedSearch = new function() { this.onLoad = onLoad; this.search = search; this.clear = clear; - this.save = save; this.onDblClick = onDblClick; this.onUnload = onUnload; @@ -104,13 +103,13 @@ var ZoteroAdvancedSearch = new function() { } - function save() { + this.save = Zotero.Promise.coroutine(function* () { _searchBox.updateSearch(); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); - var untitled = Zotero.DB.getNextName( + var untitled = yield Zotero.DB.getNextName( _searchBox.search.libraryID, 'savedSearches', 'savedSearchName', @@ -132,15 +131,12 @@ var ZoteroAdvancedSearch = new function() { name.value = untitled; } - return _searchBox.search.clone() - .then(function (s) { - s.name = name.value; - return s.save(); - }) - .then(function () { - window.close() - }); - } + var s = yield _searchBox.search.clone(); + s.name = name.value; + yield s.save(); + + window.close() + }); this.onLibraryChange = function (libraryID) { diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index e96f82ead5..230c6a1af1 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -159,7 +159,7 @@ var Zotero_Browser = new function() { var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser); if(tab.page.translators && tab.page.translators.length) { tab.page.translate.setTranslator(translator || tab.page.translators[0]); - Zotero_Browser.performTranslation(tab.page.translate); + Zotero_Browser.performTranslation(tab.page.translate); // TODO: async } } @@ -493,7 +493,7 @@ var Zotero_Browser = new function() { * have been called * @param {Zotero.Translate} translate */ - this.performTranslation = function(translate, libraryID, collection) { + this.performTranslation = Zotero.Promise.coroutine(function* (translate, libraryID, collection) { if (Zotero.locked) { Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.scrapeError")); var desc = Zotero.localeJoin([ @@ -506,15 +506,7 @@ var Zotero_Browser = new function() { return; } - if (!Zotero.stateCheck()) { - Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.scrapeError")); - var desc = Zotero.getString("ingester.scrapeErrorDescription.previousError") - + ' ' + Zotero.getString("general.restartFirefoxAndTryAgain", Zotero.appName); - Zotero_Browser.progress.addDescription(desc); - Zotero_Browser.progress.show(); - Zotero_Browser.progress.startCloseTimer(8000); - return; - } + yield Zotero.DB.waitForTransaction(); Zotero_Browser.progress.show(); Zotero_Browser.isScraping = true; @@ -615,7 +607,7 @@ var Zotero_Browser = new function() { }); translate.translate(libraryID); - } + }); ////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index f7b7c949e4..492f6d2f7f 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -47,11 +47,11 @@ Zotero_Preferences.Advanced = { }, - runIntegrityCheck: function () { + runIntegrityCheck: Zotero.Promise.coroutine(function* () { var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); - var ok = Zotero.DB.integrityCheck(); + var ok = yield Zotero.DB.integrityCheck(); if (ok) { ok = Zotero.Schema.integrityCheck(); if (!ok) { @@ -110,7 +110,7 @@ Zotero_Preferences.Advanced = { Zotero.getString('general.' + str), Zotero.getString('db.integrityCheck.' + str) + (!ok ? "\n\n" + Zotero.getString('db.integrityCheck.dbRepairTool') : '')); - }, + }), resetTranslatorsAndStyles: function () { diff --git a/chrome/content/zotero/preferences/proxyEditor.js b/chrome/content/zotero/preferences/proxyEditor.js index 542ee3b402..98347728a6 100644 --- a/chrome/content/zotero/preferences/proxyEditor.js +++ b/chrome/content/zotero/preferences/proxyEditor.js @@ -122,7 +122,7 @@ var Zotero_ProxyEditor = new function() { window, Zotero.getString("proxies.error"), Zotero.getString("proxies.error." + error, hasErrors) ); - if(window.arguments && window.arguments[0]) proxy.revert(); + if(window.arguments && window.arguments[0]) proxy.revert(); // async return false; } proxy.save(true); diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index e6339b090d..4884b93773 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -82,6 +82,7 @@ Zotero.Attachments = new function(){ yield _postProcessFile(itemID, newFile, contentType); }.bind(this)) .catch(function (e) { + Zotero.debug(e, 1); var msg = "Failed importing file " + file.path; Components.utils.reportError(msg); Zotero.debug(msg, 1); diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js index 82864be9b4..1cf5c2fb44 100644 --- a/chrome/content/zotero/xpcom/data/cachedTypes.js +++ b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -43,8 +43,8 @@ * */ Zotero.CachedTypes = function() { - var _types = []; - var _typesLoaded; + this._types = null; + this._typesArray = null; var self = this; // Override these variables in child classes @@ -57,11 +57,38 @@ Zotero.CachedTypes = function() { this.getName = getName; this.getID = getID; - this.getTypes = getTypes; + + + this.init = Zotero.Promise.coroutine(function* () { + this._types = {}; + this._typesArray = []; + + var types = yield this._getTypesFromDB(); + for (let i=0; i