Use async DB for autocomplete
This was probably hanging previously because I was passing a JS function for onProgress, which apparently isn't allowed.
This commit is contained in:
parent
b6f493207f
commit
9d3f55be51
|
@ -794,7 +794,7 @@ Zotero.DBConnection.prototype.checkException = function (e) {
|
||||||
Zotero.DBConnection.prototype.closeDatabase = function () {
|
Zotero.DBConnection.prototype.closeDatabase = function () {
|
||||||
if(this._connection) {
|
if(this._connection) {
|
||||||
this.stopDummyStatement();
|
this.stopDummyStatement();
|
||||||
this._connection.close();
|
this._connection.asyncClose();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,37 +223,8 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
|
||||||
statement = this._zotero.DB.getStatement(sql, sqlParams);
|
statement = this._zotero.DB.getStatement(sql, sqlParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable asynchronous until we figure out the hangs
|
|
||||||
if (true) {
|
|
||||||
var rows = this._zotero.DB.query(sql, sqlParams);
|
|
||||||
|
|
||||||
if (resultsCallback) {
|
|
||||||
resultsCallback(rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
var results = [];
|
|
||||||
var comments = [];
|
|
||||||
for each(var row in rows) {
|
|
||||||
results.push(row.val);
|
|
||||||
let comment = row.comment;
|
|
||||||
if (comment) {
|
|
||||||
comments.push(comment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.updateResults(results, comments);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._zotero.DB._connection.setProgressHandler(5000, {
|
|
||||||
onProgress: function (connection) {
|
|
||||||
if (self._cancelled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.pendingStatement = statement.executeAsync({
|
this.pendingStatement = statement.executeAsync({
|
||||||
handleResult: function (storageResultSet) {
|
handleResult: function (storageResultSet) {
|
||||||
self._zotero.debug("Handling autocomplete results");
|
self._zotero.debug("Handling autocomplete results");
|
||||||
|
@ -282,7 +253,7 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
|
||||||
},
|
},
|
||||||
|
|
||||||
handleError: function (e) {
|
handleError: function (e) {
|
||||||
//Components.utils.reportError(e.message);
|
Components.utils.reportError(e.message);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCompletion: function (reason) {
|
handleCompletion: function (reason) {
|
||||||
|
@ -352,10 +323,7 @@ ZoteroAutoComplete.prototype.updateResults = function (results, comments, ongoin
|
||||||
ZoteroAutoComplete.prototype.stopSearch = function(){
|
ZoteroAutoComplete.prototype.stopSearch = function(){
|
||||||
if (this.pendingStatement) {
|
if (this.pendingStatement) {
|
||||||
this._zotero.debug('Stopping autocomplete search');
|
this._zotero.debug('Stopping autocomplete search');
|
||||||
// This appears to take as long as letting the query complete,
|
this.pendingStatement.cancel();
|
||||||
// so we flag instead and abort from the progress handler
|
|
||||||
//this.pendingStatement.cancel();
|
|
||||||
this._cancelled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user