From e9552a5f60bd78cfae26849458c89d2f1747e2be Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 28 Oct 2013 17:09:09 +0100 Subject: [PATCH] can channel be undefined? --- assets/scripts/app/pusher.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 459c690d..4a86bb68 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -27,18 +27,20 @@ $.extend Travis.Pusher.prototype, @subscribe(channel) for channel in channels subscribe: (channel) -> + return unless channel channel = @prefix(channel) console.log("subscribing to #{channel}") unless @pusher?.channel(channel) @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unsubscribe: (channel) -> + return unless channel channel = @prefix(channel) console.log("unsubscribing from #{channel}") @pusher.unsubscribe(channel) if @pusher?.channel(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 processingIntervalWhenHidden: 1000 * 60 * 5