Move logic from FirstSyncView to the route
This commit is contained in:
parent
33cf63ed83
commit
83bbb1d87f
|
@ -1,9 +1,35 @@
|
|||
require 'routes/route'
|
||||
require 'routes/simple_layout'
|
||||
require 'models/repo'
|
||||
|
||||
SimpleLayoutRoute = Travis.SimpleLayoutRoute
|
||||
Repo = Travis.Repo
|
||||
|
||||
Route = SimpleLayoutRoute.extend
|
||||
activate: ->
|
||||
controller = @controllerFor('firstSync')
|
||||
controller.addObserver('isSyncing', this, @isSyncingDidChange)
|
||||
|
||||
deactivate: ->
|
||||
controller = @controllerFor('firstSync')
|
||||
controller.removeObserver('controller.isSyncing', this, @isSyncingDidChange)
|
||||
|
||||
isSyncingDidChange: ->
|
||||
controller = @controllerFor('firstSync')
|
||||
|
||||
if !controller.get('isSyncing')
|
||||
self = this
|
||||
Ember.run.later this, ->
|
||||
Repo.fetch(member: @get('controller.user.login')).then( (repos) ->
|
||||
if repos.get('length')
|
||||
self.transitionTo('main')
|
||||
else
|
||||
self.transitionTo('profile')
|
||||
).then(null, (e) ->
|
||||
console.log('There was a problem while redirecting from first sync', e)
|
||||
)
|
||||
, @get('config').syncingPageRedirectionTime
|
||||
|
||||
actions:
|
||||
redirectToGettingStarted: ->
|
||||
# do nothing, we are showing first sync, so it's normal that there is
|
||||
|
|
|
@ -24,26 +24,6 @@ Travis.InsufficientOauthPermissionsView = Travis.View.extend
|
|||
Travis.FirstSyncView = Travis.View.extend
|
||||
layoutName: 'layouts/simple'
|
||||
classNames: ['application']
|
||||
didInsertElement: ->
|
||||
this.addObserver('controller.isSyncing', this, this.isSyncingDidChange)
|
||||
|
||||
willDestroyElement: ->
|
||||
this.removeObserver('controller.isSyncing', this, this.isSyncingDidChange)
|
||||
|
||||
isSyncingDidChange: ->
|
||||
if !@get('controller.isSyncing')
|
||||
self = this
|
||||
Ember.run.later this, ->
|
||||
Travis.Repo.fetch(member: @get('controller.user.login')).then( (repos) ->
|
||||
if repos.get('length')
|
||||
self.get('controller').transitionToRoute('index')
|
||||
else
|
||||
self.get('controller').transitionToRoute('profile')
|
||||
).then(null, (e) ->
|
||||
console.log('There was a problem while redirecting from first sync', e)
|
||||
)
|
||||
, Travis.config.syncingPageRedirectionTime
|
||||
|
||||
|
||||
Travis.SidebarView = Travis.View.extend
|
||||
classQueues: (->
|
||||
|
|
Loading…
Reference in New Issue
Block a user