From 0d2794531a6190d78b2a4bcaa4fb4fa66a4b0d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 14 Oct 2016 15:46:23 +0300 Subject: [PATCH] Better progress window handling for feed item scraping --- chrome/content/zotero/browser.js | 2 -- chrome/content/zotero/xpcom/data/feedItem.js | 17 ++++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 9aec383b7f..df01f81ee0 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -100,8 +100,6 @@ var Zotero_Browser = new function() { function init() { // No gBrowser - running in standalone if (!window.hasOwnProperty("gBrowser")) { - // We can still have a progress window in this though - reload(); return; } diff --git a/chrome/content/zotero/xpcom/data/feedItem.js b/chrome/content/zotero/xpcom/data/feedItem.js index fe725374a4..5c3a1558be 100644 --- a/chrome/content/zotero/xpcom/data/feedItem.js +++ b/chrome/content/zotero/xpcom/data/feedItem.js @@ -217,20 +217,19 @@ Zotero.FeedItem.prototype.translate = Zotero.Promise.coroutine(function* (librar let deferred = Zotero.Promise.defer(); let error = function(e) { Zotero.debug(e, 1); deferred.reject(e); }; let translate = new Zotero.Translate.Web(); + let progressWindow = new Zotero.ProgressWindow(); if (libraryID) { - // Show progress notifications when scraping to a library. Shown under the most recent - // window (Zotero Pane). Browser window not available in standalone. - var win = Services.wm.getMostRecentWindow(null); + // Show progress notifications when scraping to a library. translate.clearHandlers("done"); translate.clearHandlers("itemDone"); - translate.setHandler("done", win.Zotero_Browser.progress.Translation.doneHandler); - translate.setHandler("itemDone", win.Zotero_Browser.progress.Translation.itemDoneHandler()); + translate.setHandler("done", progressWindow.Translation.doneHandler); + translate.setHandler("itemDone", progressWindow.Translation.itemDoneHandler()); if (collectionID) { var collection = yield Zotero.Collections.getAsync(collectionID); } - win.Zotero_Browser.progress.show(); - win.Zotero_Browser.progress.Translation.scrapingTo(libraryID, collection); + progressWindow.show(); + progressWindow.Translation.scrapingTo(libraryID, collection); } // Load document @@ -269,8 +268,8 @@ Zotero.FeedItem.prototype.translate = Zotero.Promise.coroutine(function* (librar }); } - win.Zotero_Browser.progress.Translation.itemDoneHandler()(null, null, item); - win.Zotero_Browser.progress.Translation.doneHandler(null, true); + progressWindow.Translation.itemDoneHandler()(null, null, item); + progressWindow.Translation.doneHandler(null, true); return; } translate.setTranslator(translators[0]);