From 9d710ea13588185e2b71e84b875e742a6dc0ccf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 21 Nov 2023 10:34:36 +0200 Subject: [PATCH] Be less aggressive about sending Zotero to back after http integration commands Report https://forums.zotero.org/discussion/109479/bug-after-adding-citation-main-window-is-hidden-76 --- chrome/content/zotero/xpcom/integration.js | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index cfcb4ba549..bbac2407b3 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -309,15 +309,25 @@ Zotero.Integration = new function() { finally { var diff = ((new Date()).getTime() - startTime)/1000; Zotero.debug(`Integration: ${agent}-${command}${docId ? `:'${docId}'` : ''} complete in ${diff}s`) + + if (Zotero.Integration.currentWindow && !Zotero.Integration.currentWindow.closed) { + var oldWindow = Zotero.Integration.currentWindow; + oldWindow.close(); + await Zotero.Promise.delay(50); + } + + if (Zotero.Integration.currentSession && Zotero.Integration.currentSession.progressBar) { + Zotero.Integration.currentSession.progressBar.hide(); + await Zotero.Promise.delay(50); + } + if (document) { try { await document.cleanup(); await document.activate(); // Call complete function if one exists - if (document.wrappedJSObject && document.wrappedJSObject.complete) { - document.wrappedJSObject.complete(); - } else if (document.complete) { + if (document.complete) { await document.complete(); } } catch(e) { @@ -325,18 +335,6 @@ Zotero.Integration = new function() { } } - if(Zotero.Integration.currentWindow && !Zotero.Integration.currentWindow.closed) { - var oldWindow = Zotero.Integration.currentWindow; - Zotero.Promise.delay(100).then(function() { - oldWindow.close(); - }); - } - - if (Zotero.Integration.currentSession && Zotero.Integration.currentSession.progressBar) { - Zotero.Promise.delay(5).then(function() { - Zotero.Integration.currentSession.progressBar.hide(); - }); - } // This technically shouldn't be necessary since we call document.activate(), // but http integration plugins may not have OS level access to windows to be // able to activate themselves. E.g. Google Docs on Safari.