From 35b059e783ad4f58714ccf3b479abf12fd779fe7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 6 Jan 2015 18:14:19 +0100 Subject: [PATCH] Fix initialization for pro --- assets/scripts/app/app.coffee | 71 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/assets/scripts/app/app.coffee b/assets/scripts/app/app.coffee index 4fbe783c..e912437c 100644 --- a/assets/scripts/app/app.coffee +++ b/assets/scripts/app/app.coffee @@ -47,6 +47,12 @@ unless window.TravisApplication @tailing = new Travis.Tailing($(window), '#tail', '#log') @toTop = new Travis.ToTop($(window), '.to-top', '#log-container') + @on 'user:signed_in', (user) -> + Travis.onUserUpdate(user) + + @on 'user:synced', (user) -> + Travis.onUserUpdate(user) + reset: -> @_super.apply(this, arguments) @get('modelClasses').forEach (klass) -> @@ -144,46 +150,37 @@ unless window.TravisApplication currentDate: -> new Date() - ) - onUserUpdate: (user) -> - if Travis.config.pro - @identifyCustomer(user) - @subscribePusher(user) - @setupCharm(user) + onUserUpdate: (user) -> + if Travis.config.pro + @identifyCustomer(user) + @subscribePusher(user) + @setupCharm(user) - subscribePusher: (user) -> - channels = user.channels - channels = channels.map (channel) -> - if channel.match /^private-/ - channel - else - "private-#{channel}" - Travis.pusher.subscribeAll(channels) + subscribePusher: (user) -> + channels = user.channels + channels = channels.map (channel) -> + if channel.match /^private-/ + channel + else + "private-#{channel}" + Travis.pusher.subscribeAll(channels) - setupCharm: (user) -> - $.extend window.__CHARM, - customer: user.login, - customer_id: user.id, - email: user.email - - displayCharm: -> - __CHARM.show() - - identifyCustomer: (user) -> - if _cio && _cio.identify - _cio.identify - id: user.id + setupCharm: (user) -> + $.extend window.__CHARM, + customer: user.login, + customer_id: user.id, email: user.email - name: user.name - created_at: (Date.parse(user.created_at) / 1000) || null - login: user.login - @on 'user:signed_in', (user) -> - Travis.onUserUpdate(user) - - @on 'user:synced', (user) -> - Travis.onUserUpdate(user) - - @_super.apply this, arguments + displayCharm: -> + __CHARM.show() + identifyCustomer: (user) -> + if _cio && _cio.identify + _cio.identify + id: user.id + email: user.email + name: user.name + created_at: (Date.parse(user.created_at) / 1000) || null + login: user.login + )