Return a promise from Zotero.shutdown()

This commit is contained in:
Simon Kornblith 2013-08-09 11:10:38 -04:00
parent 8a8093028d
commit a723c85999
2 changed files with 16 additions and 36 deletions

View file

@ -164,16 +164,11 @@ ZoteroContext.prototype = {
*/
"switchConnectorMode":function(isConnector) {
if(isConnector !== this.isConnector) {
zContext.Zotero.shutdown(function() {
try {
// create a new zContext
makeZoteroContext(isConnector);
zContext.Zotero.init();
} catch(e) {
dump(e.toSource());
throw e;
}
});
zContext.Zotero.shutdown().then(function() {
// create a new zContext
makeZoteroContext(isConnector);
zContext.Zotero.init();
}).done();
}
return zContext;
@ -297,23 +292,11 @@ function ZoteroService() {
try {
zContext.Zotero.init();
} catch(e) {
if(e === "ZOTERO_SHOULD_START_AS_CONNECTOR") {
// if Zotero should start as a connector, reload it
zContext.Zotero.shutdown(function() {
try {
makeZoteroContext(true);
zContext.Zotero.init();
} catch(e) {
dump(e.toSource());
Components.utils.reportError(e);
throw e;
}
});
} else {
dump(e.toSource());
Components.utils.reportError(e);
throw e;
}
// if Zotero should start as a connector, reload it
zContext.Zotero.shutdown().then(function() {
makeZoteroContext(true);
zContext.Zotero.init();
}).done();
}
}
isFirstLoadThisSession = false; // no longer first load