can channel be undefined?

This commit is contained in:
Sven Fuchs 2013-10-28 17:09:09 +01:00
parent 5130726389
commit e9552a5f60

View File

@ -27,18 +27,20 @@ $.extend Travis.Pusher.prototype,
@subscribe(channel) for channel in channels @subscribe(channel) for channel in channels
subscribe: (channel) -> subscribe: (channel) ->
return unless channel
channel = @prefix(channel) channel = @prefix(channel)
console.log("subscribing to #{channel}") console.log("subscribing to #{channel}")
unless @pusher?.channel(channel) unless @pusher?.channel(channel)
@pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data))
unsubscribe: (channel) -> unsubscribe: (channel) ->
return unless channel
channel = @prefix(channel) channel = @prefix(channel)
console.log("unsubscribing from #{channel}") console.log("unsubscribing from #{channel}")
@pusher.unsubscribe(channel) if @pusher?.channel(channel) @pusher.unsubscribe(channel) if @pusher?.channel(channel)
prefix: (channel) -> prefix: (channel) ->
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" unless channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) == 0 "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" if channel && channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) != 0
# process pusher messages in batches every 5 minutes when the page is hidden # process pusher messages in batches every 5 minutes when the page is hidden
processingIntervalWhenHidden: 1000 * 60 * 5 processingIntervalWhenHidden: 1000 * 60 * 5