travis-web/assets/scripts/app/routes/main.coffee
Piotr Sarnacki 5065bb5739 Subscribe to pusher channels only when entering the MainRoute
We don't want to subscribe if we're at any other routes, because there is no
data there. The main target is to avoid all of the notifications from a common
channel if we're on the /dashboard route.
2015-01-15 10:36:35 +01:00

26 lines
653 B
CoffeeScript

require 'routes/route'
require 'pusher'
TravisRoute = Travis.Route
channels = Travis.Pusher.CHANNELS
Route = TravisRoute.extend
renderTemplate: ->
$('body').attr('id', 'home')
@_super.apply this, arguments
@render 'repos', outlet: 'left', into: 'main'
setupController: (controller)->
# TODO: this is redundant with repositories and recent routes
toActivate = if @signedIn() then 'owned' else 'recent'
@container.lookup('controller:repos').activate(toActivate)
activate: ->
# subscribe to pusher only if we're at a main route
if channels
@get('pusher').subscribeAll(channels)
Travis.MainRoute = Route