mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
remove listening event, add logic to started and stopped events
This commit is contained in:
@@ -12,15 +12,16 @@ class HostStatusBar extends View
|
||||
if @session.isListening()
|
||||
@session.stop()
|
||||
else
|
||||
@status.addClass('running') # for immediate feedback to user
|
||||
@session.start()
|
||||
|
||||
@session.on 'listening started stopped participant-entered participant-exited', @update
|
||||
@session.on 'started stopped participant-entered participant-exited', @update
|
||||
@update()
|
||||
|
||||
update: =>
|
||||
if @session.isListening()
|
||||
@status.addClass('running')
|
||||
@connections.show().text(@session.participants.length)
|
||||
@connections.show().text(@session.getOtherParticipants().length)
|
||||
else
|
||||
@status.removeClass('running')
|
||||
@connections.hide()
|
||||
|
||||
@@ -32,7 +32,9 @@ class Session
|
||||
start: ->
|
||||
@channel = @subscribe(@id)
|
||||
|
||||
@channel.on 'channel:closed', => @trigger 'stopped'
|
||||
@channel.on 'channel:closed', =>
|
||||
@listening = false
|
||||
@trigger 'stopped'
|
||||
|
||||
@channel.on 'channel:participant-entered', (participant) =>
|
||||
@participants.push(participant)
|
||||
@@ -50,6 +52,7 @@ class Session
|
||||
|
||||
@connectDocument()
|
||||
@channel.one 'channel:subscribed', (@participants) =>
|
||||
@listening = true
|
||||
@trigger 'started', @getParticipants()
|
||||
|
||||
@on 'participant-entered', =>
|
||||
@@ -60,9 +63,6 @@ class Session
|
||||
repoSnapshot: repoSnapshot
|
||||
@channel.send 'welcome', welcomePackage
|
||||
|
||||
@listening = true
|
||||
@trigger 'listening'
|
||||
|
||||
else
|
||||
@channel.one 'channel:subscribed', (@participants) =>
|
||||
@channel.one 'welcome', ({doc, siteId, repoSnapshot}) =>
|
||||
|
||||
Reference in New Issue
Block a user