Use per repo channels instead of common channel
This commit is contained in:
parent
af8df832f7
commit
1365caae9a
|
@ -52,6 +52,9 @@ App = Ember.Application.extend(Ember.Evented,
|
||||||
@on 'user:signed_in', (user) ->
|
@on 'user:signed_in', (user) ->
|
||||||
Travis.onUserUpdate(user)
|
Travis.onUserUpdate(user)
|
||||||
|
|
||||||
|
@on 'user:refreshed', (user) ->
|
||||||
|
Travis.onUserUpdate(user)
|
||||||
|
|
||||||
@on 'user:synced', (user) ->
|
@on 'user:synced', (user) ->
|
||||||
Travis.onUserUpdate(user)
|
Travis.onUserUpdate(user)
|
||||||
|
|
||||||
|
@ -61,16 +64,20 @@ App = Ember.Application.extend(Ember.Evented,
|
||||||
onUserUpdate: (user) ->
|
onUserUpdate: (user) ->
|
||||||
if config.pro
|
if config.pro
|
||||||
@identifyCustomer(user)
|
@identifyCustomer(user)
|
||||||
@subscribePusher(user)
|
|
||||||
@setupCharm(user)
|
@setupCharm(user)
|
||||||
|
|
||||||
|
@subscribePusher(user)
|
||||||
|
|
||||||
subscribePusher: (user) ->
|
subscribePusher: (user) ->
|
||||||
|
return unless user.channels
|
||||||
channels = user.channels
|
channels = user.channels
|
||||||
|
if config.pro
|
||||||
channels = channels.map (channel) ->
|
channels = channels.map (channel) ->
|
||||||
if channel.match /^private-/
|
if channel.match /^private-/
|
||||||
channel
|
channel
|
||||||
else
|
else
|
||||||
"private-#{channel}"
|
"private-#{channel}"
|
||||||
|
|
||||||
Travis.pusher.subscribeAll(channels)
|
Travis.pusher.subscribeAll(channels)
|
||||||
|
|
||||||
setupCharm: (user) ->
|
setupCharm: (user) ->
|
||||||
|
|
|
@ -19,6 +19,24 @@ Route = TravisRoute.extend BuildFaviconMixin,
|
||||||
activate: ->
|
activate: ->
|
||||||
@get('stylesheetsManager').disable('dashboard')
|
@get('stylesheetsManager').disable('dashboard')
|
||||||
|
|
||||||
|
if !config.pro
|
||||||
|
repos = @get('store').all('repo')
|
||||||
|
repos.forEach (repo) =>
|
||||||
|
@subscribeToRepo(repo)
|
||||||
|
|
||||||
|
repos.addArrayObserver(this, willChange: 'reposWillChange', didChange: 'reposDidChange')
|
||||||
|
|
||||||
|
reposWillChange: (->)
|
||||||
|
|
||||||
|
reposDidChange: (array, start, removedCount, addedCount) ->
|
||||||
|
addedRepos = array.slice(start, start + addedCount)
|
||||||
|
addedRepos.forEach (repo) =>
|
||||||
|
@subscribeToRepo(repo)
|
||||||
|
|
||||||
|
subscribeToRepo: (repo) ->
|
||||||
|
if @pusher
|
||||||
|
@pusher.subscribe "repo-#{repo.get('id')}"
|
||||||
|
|
||||||
title: (titleParts) ->
|
title: (titleParts) ->
|
||||||
if titleParts.length
|
if titleParts.length
|
||||||
titleParts = titleParts.reverse()
|
titleParts = titleParts.reverse()
|
||||||
|
|
|
@ -16,9 +16,4 @@ Route = TravisRoute.extend
|
||||||
# TODO: this is redundant with repositories and recent routes
|
# TODO: this is redundant with repositories and recent routes
|
||||||
@container.lookup('controller:repos').activate('owned')
|
@container.lookup('controller:repos').activate('owned')
|
||||||
|
|
||||||
activate: ->
|
|
||||||
# subscribe to pusher only if we're at a main route
|
|
||||||
if !config.pro && @pusher
|
|
||||||
@pusher.subscribeAll(['common'])
|
|
||||||
|
|
||||||
`export default Route`
|
`export default Route`
|
||||||
|
|
|
@ -95,6 +95,7 @@ Auth = Ember.Object.extend
|
||||||
data.user.token = user.token
|
data.user.token = user.token
|
||||||
@storeData(data, @sessionStorage)
|
@storeData(data, @sessionStorage)
|
||||||
@storeData(data, @storage)
|
@storeData(data, @storage)
|
||||||
|
Travis.trigger('user:refreshed', data.user)
|
||||||
else
|
else
|
||||||
@signOut()
|
@signOut()
|
||||||
, (status, xhr) =>
|
, (status, xhr) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user