Pump a generator when reading out citations from document to keep UI responsive
This commit is contained in:
parent
49380e39ac
commit
251da6ce50
1 changed files with 77 additions and 66 deletions
|
@ -1010,16 +1010,18 @@ Zotero.Integration.Fields.prototype.updateSession = function(callback) {
|
|||
if(me._session.reload) {
|
||||
//this._session.restoreProcessorState(); TODO doesn't appear to be working properly
|
||||
me._session.updateUpdateIndices();
|
||||
var deleteCitations = me._session.updateCitations();
|
||||
Zotero.pumpGenerator(me._session.updateCitations(function(deleteCitations) {
|
||||
me._deleteFields = me._deleteFields.concat([i for(i in deleteCitations)]);
|
||||
me._session.updateIndices = {};
|
||||
me._session.updateItemIDs = {};
|
||||
me._session.citationText = {};
|
||||
me._session.bibliographyHasChanged = false;
|
||||
delete me._session.reload;
|
||||
}
|
||||
|
||||
if(callback) callback(me._session);
|
||||
}));
|
||||
} else {
|
||||
if(callback) callback(this._session);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1109,7 +1111,13 @@ Zotero.Integration.Fields.prototype._processFields = function(fields, callback,
|
|||
*/
|
||||
Zotero.Integration.Fields.prototype.updateDocument = function(forceCitations, forceBibliography,
|
||||
ignoreCitationChanges, callback) {
|
||||
Zotero.pumpGenerator(this._updateDocument(forceCitations, forceBibliography, ignoreCitationChanges, callback));
|
||||
// update citations
|
||||
this._session.updateUpdateIndices(forceCitations);
|
||||
var me = this;
|
||||
var deleteCitations = Zotero.pumpGenerator(this._session.updateCitations(function(deleteCitations) {
|
||||
Zotero.pumpGenerator(me._updateDocument(forceCitations, forceBibliography,
|
||||
ignoreCitationChanges, deleteCitations, callback));
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1120,11 +1128,9 @@ Zotero.Integration.Fields.prototype.updateDocument = function(forceCitations, fo
|
|||
* modified since they were created, instead of showing a warning
|
||||
*/
|
||||
Zotero.Integration.Fields.prototype._updateDocument = function(forceCitations, forceBibliography,
|
||||
ignoreCitationChanges, callback) {
|
||||
ignoreCitationChanges, deleteCitations, callback) {
|
||||
try {
|
||||
// update citations
|
||||
this._session.updateUpdateIndices(forceCitations);
|
||||
var deleteCitations = this._session.updateCitations();
|
||||
this._deleteFields = this._deleteFields.concat([i for(i in deleteCitations)]);
|
||||
|
||||
if(this.progressCallback) {
|
||||
|
@ -2159,7 +2165,8 @@ Zotero.Integration.Session.prototype.formatCitation = function(index, citation)
|
|||
/**
|
||||
* Updates the list of citations to be serialized to the document
|
||||
*/
|
||||
Zotero.Integration.Session.prototype.updateCitations = function() {
|
||||
Zotero.Integration.Session.prototype.updateCitations = function(callback) {
|
||||
try {
|
||||
/*var allUpdatesForced = false;
|
||||
var forcedUpdates = {};
|
||||
if(force) {
|
||||
|
@ -2208,6 +2215,7 @@ Zotero.Integration.Session.prototype.updateCitations = function() {
|
|||
this.citationIDs[citation.citationID] = citation;
|
||||
}
|
||||
delete this.newIndices[index];
|
||||
yield true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2216,7 +2224,10 @@ Zotero.Integration.Session.prototype.updateCitations = function() {
|
|||
this.updateIndices = {};
|
||||
}*/
|
||||
|
||||
return deleteCitations;
|
||||
callback(deleteCitations);
|
||||
} catch(e) {
|
||||
Zotero.Integration.handleError(e, this._doc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue