add private attribute to repo, prefix job channels based on the private status, otherwise use what api hands over
This commit is contained in:
parent
aa286866a8
commit
1951784c28
|
@ -93,17 +93,18 @@ require 'travis/model'
|
||||||
return if @get('subscribed')
|
return if @get('subscribed')
|
||||||
@set('subscribed', true)
|
@set('subscribed', true)
|
||||||
if Travis.pusher
|
if Travis.pusher
|
||||||
Travis.pusher.subscribe "job-#{@get('id')}"
|
prefix = if @get('repo.private') then 'private-' else ''
|
||||||
|
Travis.pusher.subscribe "#{prefix}job-#{@get('id')}",
|
||||||
|
|
||||||
unsubscribe: ->
|
unsubscribe: ->
|
||||||
return unless @get('subscribed')
|
return unless @get('subscribed')
|
||||||
@set('subscribed', false)
|
@set('subscribed', false)
|
||||||
if Travis.pusher
|
if Travis.pusher
|
||||||
|
prefix = if @get('repo.private') then 'private-' else ''
|
||||||
Travis.pusher.unsubscribe "job-#{@get('id')}"
|
Travis.pusher.unsubscribe "job-#{@get('id')}"
|
||||||
|
|
||||||
onStateChange: (->
|
onStateChange: (->
|
||||||
if @get('state') == 'finished' && Travis.pusher
|
@unsubscribe() if @get('state') == 'finished' && Travis.pusher
|
||||||
Travis.pusher.unsubscribe "job-#{@get('id')}"
|
|
||||||
).observes('state')
|
).observes('state')
|
||||||
|
|
||||||
isPropertyLoaded: (key) ->
|
isPropertyLoaded: (key) ->
|
||||||
|
|
|
@ -5,6 +5,7 @@ require 'travis/model'
|
||||||
id: Ember.attr('string')
|
id: Ember.attr('string')
|
||||||
slug: Ember.attr('string')
|
slug: Ember.attr('string')
|
||||||
description: Ember.attr('string')
|
description: Ember.attr('string')
|
||||||
|
private: Ember.attr('boolean')
|
||||||
lastBuildId: Ember.attr('string')
|
lastBuildId: Ember.attr('string')
|
||||||
lastBuildNumber: Ember.attr(Number)
|
lastBuildNumber: Ember.attr(Number)
|
||||||
lastBuildState: Ember.attr('string')
|
lastBuildState: Ember.attr('string')
|
||||||
|
|
|
@ -4,7 +4,6 @@ Travis.Pusher = (key) ->
|
||||||
|
|
||||||
$.extend Travis.Pusher,
|
$.extend Travis.Pusher,
|
||||||
CHANNELS: ['common']
|
CHANNELS: ['common']
|
||||||
CHANNEL_PREFIX: ''
|
|
||||||
ENCRYPTED: false
|
ENCRYPTED: false
|
||||||
|
|
||||||
$.extend Travis.Pusher.prototype,
|
$.extend Travis.Pusher.prototype,
|
||||||
|
@ -27,19 +26,14 @@ $.extend Travis.Pusher.prototype,
|
||||||
@subscribe(channel) for channel in channels
|
@subscribe(channel) for channel in channels
|
||||||
|
|
||||||
subscribe: (channel) ->
|
subscribe: (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) ->
|
||||||
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) ->
|
|
||||||
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}"
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user