commit 401f766e9a966cc21fb3a519a2b25146640ca810
parent dd89fb6d47524a51790e497522c6c764e51dd9ac
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 14 Sep 2009 06:13:04 +0000
- Fix broken charset detection and full-text indexing during import on trunk
- Fix collection refresh after import
Diffstat:
4 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js
@@ -301,7 +301,10 @@ var Zotero_File_Interface = new function() {
Zotero_File_Interface.Progress.close();
Zotero.UnresponsiveScriptIndicator.enable();
- if(!worked) {
+ if (worked) {
+ Zotero.Notifier.trigger('refresh', 'collection', _importCollection.id);
+ }
+ else {
_importCollection.erase();
window.alert(Zotero.getString("fileInterface.importError"));
}
diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js
@@ -1289,20 +1289,32 @@ Zotero.Attachments = new function(){
// ignore spurious about:blank loads
if(browser.contentDocument.location.href == "about:blank") return;
- var charsetID = Zotero.CharacterSets.getID(charset);
- if (charsetID) {
- var disabled = Zotero.Notifier.disable();
- var item = Zotero.Items.get(itemID);
- item.attachmentCharset = charsetID;
- item.save();
- if (disabled) {
- Zotero.Notifier.enable();
+ var writeCallback = function () {
+ var charsetID = Zotero.CharacterSets.getID(charset);
+ if (charsetID) {
+ var disabled = Zotero.Notifier.disable();
+
+ var item = Zotero.Items.get(itemID);
+ item.attachmentCharset = charsetID;
+ item.save();
+
+ if (disabled) {
+ Zotero.Notifier.enable();
+ }
}
+
+ // Chain fulltext indexer inside the charset callback,
+ // since it's asynchronous and a prerequisite
+ Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
}
- // Chain fulltext indexer inside the charset callback,
- // since it's asynchronous and a prerequisite
- Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
+ // Since the callback can be called during an import process that uses
+ // Zotero.wait(), try to queue the callback to run at the end,
+ // or run now if not queued
+ var queued = Zotero.addUnlockCallback(writeCallback);
+ if (!queued) {
+ writeCallback();
+ }
};
Zotero.File.addCharsetListener(browser, callback, itemID);
diff --git a/chrome/content/zotero/xpcom/notifier.js b/chrome/content/zotero/xpcom/notifier.js
@@ -99,6 +99,7 @@ Zotero.Notifier = new function(){
**/
function trigger(event, type, ids, extraData, force){
if (_disabled){
+ Zotero.debug("Notifications are disabled");
return false;
}
@@ -327,7 +328,7 @@ Zotero.Notifier = new function(){
}
- function enable(enable) {
+ function enable() {
Zotero.debug('Enabling Notifier notifications');
_disabled = false;
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -143,7 +143,6 @@ var Zotero = new function(){
*/
this.__defineGetter__('locked', function () _locked);
-
var _startupError;
var _startupErrorHandler;
var _zoteroDirectory = false;
@@ -152,6 +151,7 @@ var Zotero = new function(){
var _waiting;
var _locked;
+ var _unlockCallbacks = [];
var _progressMeters;
var _lastPercentage;
@@ -1132,6 +1132,14 @@ var Zotero = new function(){
* Hide Zotero pane overlay in all windows
*/
this.hideZoteroPaneOverlay = function () {
+ // Run any queued callbacks
+ if (_unlockCallbacks.length) {
+ var func;
+ while (func = _unlockCallbacks.shift()) {
+ func();
+ }
+ }
+
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var enumerator = wm.getEnumerator("navigator:browser");
@@ -1145,6 +1153,20 @@ var Zotero = new function(){
}
+ /**
+ * Adds a callback to be called when the Zotero pane overlay closes
+ *
+ * @param {Boolean} TRUE if added, FALSE if not locked
+ */
+ this.addUnlockCallback = function (callback) {
+ if (!_locked) {
+ return false;
+ }
+ _unlockCallbacks.push(callback);
+ return true;
+ }
+
+
function _showWindowZoteroPaneOverlay(win) {
win.document.getElementById('zotero-collections-tree').disabled = true;
win.document.getElementById('zotero-items-tree').disabled = true;