Skip to content

Commit

Permalink
Merge branch 'master' of github.com:buddycloud/buddycloud-webclient
Browse files Browse the repository at this point in the history
  • Loading branch information
dodo committed Oct 1, 2011
2 parents 82da359 + 8ce10b7 commit f0c16c1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions brunch/src/app/views/home/show.coffee
Expand Up @@ -20,7 +20,7 @@ class exports.HomeView extends Backbone.View
@channels.add channel
@new_channel_view channel
# Attempt to come up with a default channel:
if !@current and channel.get('id') is app.users.current.get('id')
if !@current? and (channel.get('id') is app.users.current.get('id'))
@setCurrentChannel channel

@channels.bind 'change', @new_channel_view
Expand All @@ -47,20 +47,16 @@ class exports.HomeView extends Backbone.View
view

setCurrentChannel: (channel) =>
@hideCurrent?()

if (@current = @views[channel.cid])
# Present-before view
@hideCurrent = =>
@current.el.hide()
else
# Temporary view not added by @channels.bind('add')
@current = @views[channel.cid] = @new_channel_view channel
@hideCurrent = =>
@current.el.hide()
# Dispose when hiding:
delete @views[channel.cid]
app.router.navigate @current.model.get('id'), true
@current?.el.hide()
# Throw away if current user did not subscribe:
oldChannel = @current?.model
if oldChannel and !app.users.current.channels.get(oldChannel.get('id'))?
delete @views[oldChannel.cid]

unless (@current = @views[channel.cid])
@current = @new_channel_view channel
# Indicate url change without routing:
app.router.navigate @current.model.get('id'), false

@sidebar.setCurrentEntry channel
@current.el.show()
Expand Down

0 comments on commit f0c16c1

Please sign in to comment.