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
This commit is contained in:
parent
acb70dcac7
commit
e8ad482434
|
@ -8,6 +8,7 @@ Controller = Ember.Controller.extend GithubUrlPropertievs,
|
||||||
commitBinding: 'build.commit'
|
commitBinding: 'build.commit'
|
||||||
currentUserBinding: 'controllers.repo.currentUser'
|
currentUserBinding: 'controllers.repo.currentUser'
|
||||||
tabBinding: 'controllers.repo.tab'
|
tabBinding: 'controllers.repo.tab'
|
||||||
|
sendFaviconStateChanges: true
|
||||||
|
|
||||||
currentItemBinding: 'build'
|
currentItemBinding: 'build'
|
||||||
|
|
||||||
|
@ -24,7 +25,8 @@ Controller = Ember.Controller.extend GithubUrlPropertievs,
|
||||||
).property('commit.authorEmail')
|
).property('commit.authorEmail')
|
||||||
|
|
||||||
buildStateDidChange: (->
|
buildStateDidChange: (->
|
||||||
@send('faviconStateDidChange', @get('build.state'))
|
if @get('sendFaviconStateChanges')
|
||||||
|
@send('faviconStateDidChange', @get('build.state'))
|
||||||
).observes('build.state')
|
).observes('build.state')
|
||||||
|
|
||||||
`export default Controller`
|
`export default Controller`
|
||||||
|
|
|
@ -20,13 +20,24 @@ Route = TravisRoute.extend
|
||||||
|
|
||||||
if build = model.get('build')
|
if build = model.get('build')
|
||||||
build = @store.recordForId('build', build.get('id'))
|
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) ->
|
model: (params) ->
|
||||||
@store.find('job', params.job_id)
|
@store.find('job', params.job_id)
|
||||||
|
|
||||||
deactivate: ->
|
deactivate: ->
|
||||||
|
buildController = @controllerFor('build')
|
||||||
|
buildController.set('sendFaviconStateChanges', true)
|
||||||
@controllerFor('build').set('build', null)
|
@controllerFor('build').set('build', null)
|
||||||
@controllerFor('job').set('job', null)
|
@controllerFor('job').set('job', null)
|
||||||
|
|
||||||
|
@_super.apply(this, arguments)
|
||||||
|
|
||||||
`export default Route`
|
`export default Route`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user