Don't show progress window for PDF recognition if only one file
This commit is contained in:
parent
7ecaab73a0
commit
be8db4fc50
2 changed files with 22 additions and 5 deletions
|
@ -69,6 +69,10 @@ Zotero.ProgressQueueDialog = function (progressQueue) {
|
|||
_showMinimize = show;
|
||||
};
|
||||
|
||||
this.isOpen = function () {
|
||||
return !!_progressWindow;
|
||||
};
|
||||
|
||||
this.close = function () {
|
||||
// In case close() is called before open()
|
||||
if (!_progressWindow) {
|
||||
|
|
|
@ -105,7 +105,7 @@ Zotero.RecognizePDF = new function () {
|
|||
* Adds items to the queue and triggers processing
|
||||
* @param {Zotero.Item[]} items
|
||||
*/
|
||||
this.recognizeItems = function (items) {
|
||||
this.recognizeItems = async function (items) {
|
||||
for (let item of items) {
|
||||
if(
|
||||
_processingItemID === item.id ||
|
||||
|
@ -117,7 +117,7 @@ Zotero.RecognizePDF = new function () {
|
|||
_queue.unshift(item.id);
|
||||
_progressQueue.addRow(item);
|
||||
}
|
||||
_processQueue();
|
||||
await _processQueue();
|
||||
};
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ Zotero.RecognizePDF = new function () {
|
|||
};
|
||||
|
||||
|
||||
this.autoRecognizeItems = function (items) {
|
||||
this.autoRecognizeItems = async function (items) {
|
||||
if (!Zotero.Prefs.get('autoRecognizeFiles')) return;
|
||||
|
||||
var pdfs = items.filter((item) => {
|
||||
|
@ -144,8 +144,21 @@ Zotero.RecognizePDF = new function () {
|
|||
if (!pdfs.length) {
|
||||
return;
|
||||
}
|
||||
this.recognizeItems(pdfs);
|
||||
Zotero.ProgressQueues.get('recognize').getDialog().open();
|
||||
var queue = Zotero.ProgressQueues.get('recognize');
|
||||
var dialog = queue.getDialog();
|
||||
var numInQueue = queue.getTotal();
|
||||
var promise = this.recognizeItems(pdfs);
|
||||
// If the queue wasn't empty or more than one file is being saved, show the dialog
|
||||
if (numInQueue > 0 || pdfs.length > 1) {
|
||||
dialog.open();
|
||||
return promise;
|
||||
}
|
||||
await promise;
|
||||
// If dialog wasn't opened automatically and wasn't opened manually, clear it after
|
||||
// recognizing files
|
||||
if (!dialog.isOpen()) {
|
||||
queue.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue