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) ->
|
||||
Travis.onUserUpdate(user)
|
||||
|
||||
@on 'user:refreshed', (user) ->
|
||||
Travis.onUserUpdate(user)
|
||||
|
||||
@on 'user:synced', (user) ->
|
||||
Travis.onUserUpdate(user)
|
||||
|
||||
|
@ -61,16 +64,20 @@ App = Ember.Application.extend(Ember.Evented,
|
|||
onUserUpdate: (user) ->
|
||||
if config.pro
|
||||
@identifyCustomer(user)
|
||||
@subscribePusher(user)
|
||||
@setupCharm(user)
|
||||
|
||||
@subscribePusher(user)
|
||||
|
||||
subscribePusher: (user) ->
|
||||
return unless user.channels
|
||||
channels = user.channels
|
||||
channels = channels.map (channel) ->
|
||||
if channel.match /^private-/
|
||||
channel
|
||||
else
|
||||
"private-#{channel}"
|
||||
if config.pro
|
||||
channels = channels.map (channel) ->
|
||||
if channel.match /^private-/
|
||||
channel
|
||||
else
|
||||
"private-#{channel}"
|
||||
|
||||
Travis.pusher.subscribeAll(channels)
|
||||
|
||||
setupCharm: (user) ->
|
||||
|
|
|
@ -19,6 +19,24 @@ Route = TravisRoute.extend BuildFaviconMixin,
|
|||
activate: ->
|
||||
@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) ->
|
||||
if titleParts.length
|
||||
titleParts = titleParts.reverse()
|
||||
|
|
|
@ -16,9 +16,4 @@ Route = TravisRoute.extend
|
|||
# TODO: this is redundant with repositories and recent routes
|
||||
@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`
|
||||
|
|
|
@ -95,6 +95,7 @@ Auth = Ember.Object.extend
|
|||
data.user.token = user.token
|
||||
@storeData(data, @sessionStorage)
|
||||
@storeData(data, @storage)
|
||||
Travis.trigger('user:refreshed', data.user)
|
||||
else
|
||||
@signOut()
|
||||
, (status, xhr) =>
|
||||
|
|
Loading…
Reference in New Issue
Block a user