From e8ad4824340a17b5d1b4e7a4104ab885fea32222 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 24 Feb 2015 16:51:35 +0100 Subject: [PATCH] Make favicon work properly when viewing job Current implementation of controllers makes it hard to implement favicon changes outside of build/job controllers. The problem is that if a job is viewed, both controller are populated, which means they will both send state change events to change favicon. This commit adds a check for build controller, which allows to disable state change events when we're viewing a job --- app/controllers/build.coffee | 4 +++- app/routes/job.coffee | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controllers/build.coffee b/app/controllers/build.coffee index 6ce36f33..1f86f62c 100644 --- a/app/controllers/build.coffee +++ b/app/controllers/build.coffee @@ -8,6 +8,7 @@ Controller = Ember.Controller.extend GithubUrlPropertievs, commitBinding: 'build.commit' currentUserBinding: 'controllers.repo.currentUser' tabBinding: 'controllers.repo.tab' + sendFaviconStateChanges: true currentItemBinding: 'build' @@ -24,7 +25,8 @@ Controller = Ember.Controller.extend GithubUrlPropertievs, ).property('commit.authorEmail') buildStateDidChange: (-> - @send('faviconStateDidChange', @get('build.state')) + if @get('sendFaviconStateChanges') + @send('faviconStateDidChange', @get('build.state')) ).observes('build.state') `export default Controller` diff --git a/app/routes/job.coffee b/app/routes/job.coffee index f5b39c25..e207df5f 100644 --- a/app/routes/job.coffee +++ b/app/routes/job.coffee @@ -20,13 +20,24 @@ Route = TravisRoute.extend if build = model.get('build') build = @store.recordForId('build', build.get('id')) - @controllerFor('build').set('build', build) + buildController = @controllerFor('build') + + # this is a hack to not set favicon changes from build + # controller while we're viewing job, this should go away + # after refactoring of controllers + buildController.set('sendFaviconStateChanges', false) + + buildController.set('build', build) model: (params) -> @store.find('job', params.job_id) deactivate: -> + buildController = @controllerFor('build') + buildController.set('sendFaviconStateChanges', true) @controllerFor('build').set('build', null) @controllerFor('job').set('job', null) + @_super.apply(this, arguments) + `export default Route`