From fa7c275eaaa7dffb0858f26b13582af124ba8f80 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 2 Mar 2016 12:50:06 +0100 Subject: [PATCH] Clear timers in update-times service It's mostly relevant in tests, because service is destroyed when test end and then we don't want to run any timers. --- app/services/update-times.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/services/update-times.js b/app/services/update-times.js index 765fc387..5585ab38 100644 --- a/app/services/update-times.js +++ b/app/services/update-times.js @@ -6,12 +6,18 @@ export default Ember.Service.extend({ allowFinishedBuilds: false, init() { - Visibility.every(Config.intervals.updateTimes, this.updateTimes.bind(this)); - setInterval(this.resetAllowFinishedBuilds.bind(this), 60000); + this.set('visibilityId', Visibility.every(Config.intervals.updateTimes, this.updateTimes.bind(this))); + this.set('intervalId', setInterval(this.resetAllowFinishedBuilds.bind(this), 60000)); return this._super(...arguments); }, + willDestroy() { + Visibility.stop(this.get('visibilityId')); + clearInterval(this.get('intervalId')); + this._super(...arguments); + }, + resetAllowFinishedBuilds() { this.set('allowFinishedBuilds', true); },