Cancel pending feed update check on Zotero shutdown

This avoids errors for a missing 'feeds' table during tests, when the callback
started in Zotero.Feeds.init() runs but the Zotero object has been torn down
and the database hasn't yet been reinitialized.
This commit is contained in:
Dan Stillman 2016-05-17 11:50:26 -04:00
parent 6907af86fd
commit dd9cc40c16
2 changed files with 13 additions and 2 deletions

View file

@ -26,8 +26,18 @@
// Mimics Zotero.Libraries
Zotero.Feeds = new function() {
this.init = function () {
setTimeout(() => this.scheduleNextFeedCheck(), 5000);
}
this._timeoutID = setTimeout(() => {
this.scheduleNextFeedCheck();
this._timeoutID = null;
}, 5000);
};
this.uninit = function () {
if (this._timeoutID) {
clearTimeout(this._timeoutID);
this._timeoutID = null
}
};
this._cache = null;

View file

@ -736,6 +736,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
Zotero.Items.startEmptyTrashTimer();
Zotero.Feeds.init();
Zotero.addShutdownListener(() => Zotero.Feeds.uninit());
return true;
}