hyper-mesh
hyper-mesh copied to clipboard
HyperMesh.refresh_channels is broken for Pusher
I only found this while trying to debug why the client wasn't updating. I'm not sure where/when this breaks in use, but calling this stuff in the console breaks.
module HyperMesh
def self.refresh_channels
new_channels = pusher.channels[:channels].collect do |channel|
channel.gsub(/^#{Regexp.quote(HyperMesh.channel)}/, '')
end
end
end
This breaks because pusher.channels[:channels] is a hash of String => Hash, so it breaks when it iterates on the value (which is a Hash).
Also the gsub doesn't account for the hyphen between the HyperMesh.channel
name and the connection channel name.
Changing it to this seems to work.
module HyperMesh
def self.refresh_channels
pusher.channels[:channels].keys.map do |channel|
channel.gsub(/^#{Regexp.quote(HyperMesh.channel)}-/, '')
end
end
end