Do not trigger unnecessary reloads when locale *could* have changed

This commit is contained in:
Piotr Sarnacki 2012-10-22 21:27:03 +02:00
parent 3fdd2d50ab
commit 72f14fb594
6 changed files with 10 additions and 5 deletions

View File

@ -39,6 +39,7 @@ Travis.Router = Ember.Router.extend
@set 'repoController.lineNumberHash', match[0]
reload: ->
console.log 'Triggering reload'
url = @get('location').getURL()
@transitionTo('loading')
# Without ember next @route sometimes hit the place where HistoryLocation

View File

@ -8,8 +8,9 @@
localeDidChange: (->
if locale = Travis.app.get('auth.user.locale')
Travis.setLocale(locale)
Travis.app.get('router').reload()
if Travis.needsLocaleChange(locale)
Travis.setLocale(locale)
Travis.app.get('router').reload()
).observes('Travis.app.auth.user.locale')
click: (event) ->

View File

@ -40,6 +40,9 @@ require 'ext/ember/namespace'
I18n.locale = locale
localStorage.setItem('travis.locale', locale)
needsLocaleChange: (locale) ->
I18n.locale != locale
run: (attrs) ->
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
a6f7d323
b4eb0b8e