From 9de6a55bce956b3b65941f632be379d8dc5e8179 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 11 May 2017 01:25:39 -0400 Subject: [PATCH] Better approach to opening files after on-demand downloads Follow-up to 44507ce20b --- chrome/content/zotero/zoteroPane.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index aee8be7342..6b07b145f7 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4117,9 +4117,8 @@ var ZoteroPane = new function() return; } - let downloadedItem = item; try { - yield Zotero.Sync.Runner.downloadFile(downloadedItem); + yield Zotero.Sync.Runner.downloadFile(item); } catch (e) { // TODO: show error somewhere else @@ -4128,10 +4127,8 @@ var ZoteroPane = new function() return; } - if (!(yield downloadedItem.getFilePathAsync())) { - ZoteroPane_Local.showAttachmentNotFoundDialog( - downloadedItem.id, noLocateOnMissing, true - ); + if (!(yield item.getFilePathAsync())) { + ZoteroPane_Local.showAttachmentNotFoundDialog(item.id, noLocateOnMissing, true); return; } @@ -4139,9 +4136,8 @@ var ZoteroPane = new function() // maybe not necessary, since we'll get an error if there's an error Zotero.Notifier.trigger('redraw', 'item', []); - setTimeout(() => { - ZoteroPane_Local.viewAttachment(downloadedItem.id, event, false, forceExternalViewer); - }); + // Retry after download + i--; } } }));