Automatically redirect away from 'first_sync' after synced is finished

This commit is contained in:
Piotr Sarnacki 2013-08-06 14:55:02 +02:00
parent d2ebf4cbcf
commit d3ded51a16
4 changed files with 24 additions and 3 deletions

View File

@ -39,7 +39,7 @@ Travis.ProfileLayoutController = Em.Controller.extend()
Travis.AuthLayoutController = Em.Controller.extend() Travis.AuthLayoutController = Em.Controller.extend()
Travis.AccountProfileController = Em.Controller.extend Travis.AccountProfileController = Em.Controller.extend
needs: ['currentUser'] needs: ['currentUser', 'repos']
userBinding: 'controllers.currentUser' userBinding: 'controllers.currentUser'
Travis.FirstSyncController = Em.Controller.extend Travis.FirstSyncController = Em.Controller.extend

View File

@ -24,7 +24,7 @@
{{else}} {{else}}
<h3>Great news!</h3> <h3>Great news!</h3>
<p> <p>
We've successfully synchronized your details from GitHub. Now {{#linkTo "index.current"}}go get started!{{/linkTo}} We've successfully synchronized your details from GitHub. We will redirect you to your profile in a few seconds.
</p> </p>
{{/if}} {{/if}}
</div> </div>

View File

@ -35,7 +35,7 @@
<a class="signed-out" href="#" {{action "signIn" target="Travis"}}>{{t layouts.top.github_login}}</a> <a class="signed-out" href="#" {{action "signIn" target="Travis"}}>{{t layouts.top.github_login}}</a>
{{/if}} {{/if}}
{{#if signedIn}} {{#if signedIn}}
{{#linkTo "profile.index" class="signed-in"}}<img {{bindAttr src="gravatarUrl"}}/>{{userName}}{{/linkTo}} {{#linkTo "profile" class="signed-in"}}<img {{bindAttr src="gravatarUrl"}}/>{{userName}}{{/linkTo}}
{{/if}} {{/if}}
{{#if signingIn}} {{#if signingIn}}
<span class="signing-in">{{t layouts.top.signing_in}}</span> <span class="signing-in">{{t layouts.top.signing_in}}</span>

View File

@ -24,6 +24,27 @@ Em.View.reopen
Travis.GettingStartedView = Travis.View.extend Travis.GettingStartedView = Travis.View.extend
templateName: 'no_owned_repos' templateName: 'no_owned_repos'
Travis.FirstSyncView = Travis.View.extend
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.current')
else
self.get('controller').transitionToRoute('profile')
).then(null, (e) ->
console.log('There was a problem while redirecting from first sync', e)
)
, 5000
require 'views/accounts' require 'views/accounts'
require 'views/application' require 'views/application'
require 'views/build' require 'views/build'