-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from CodersTV/fix-online-counter
Merge online counter and chatroom on coder channel
- Loading branch information
Showing
13 changed files
with
227 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,38 @@ | ||
function getCurrentCoder (coderId) { | ||
if (! coderId) { | ||
return { | ||
userId: coderId | ||
}; | ||
} | ||
|
||
var user = Meteor.users.findOne({'profile.username': coderId}), | ||
currentCoder = {coderId: coderId}; | ||
|
||
if (user) { | ||
return { | ||
userId: user._id, | ||
username: coderId, | ||
name: user.profile.name | ||
}; | ||
CoderController = RouteController.extend({ | ||
template: 'channel', | ||
waitOn: function () { | ||
return Meteor.subscribe('ChannelWithOwnerAndFollowers', this.params.coderId); | ||
}, | ||
onAfterAction: function () { | ||
var coder = Meteor.users.findOneFromCoderId(this.params.coderId); | ||
if (! _.isEmpty(coder)) { | ||
Session.set('coder', coder); | ||
Meteor.subscribe( | ||
'userPresenceWithProfile', | ||
coder.profile.username, | ||
coder._id, | ||
function () { | ||
Session.set('chatSubsReady', true); | ||
} | ||
); | ||
Session.set('currentCoder', coder._id); | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
userId: coderId | ||
}; | ||
} | ||
|
||
|
||
ChannelController = RouteController.extend({ | ||
VideoController = RouteController.extend({ | ||
template: 'channel', | ||
waitOn: function () { | ||
var path = Path.get(true); | ||
|
||
return [ | ||
Meteor.subscribe('userPresence', path), | ||
Meteor.subscribe('Channels', Session.get('channelSearchQuery')), | ||
Meteor.subscribe('Users'), | ||
Meteor.subscribe('Followers'), | ||
]; | ||
return Meteor.subscribe('VideoWithOwnerAndFollowers', this.params.videoId); | ||
}, | ||
onBeforeAction: function () { | ||
var coderId = this.params.coderId; | ||
var videoId = this.params.videoId; | ||
var currentCoder = getCurrentCoder(coderId); | ||
var currentVideo = Channel.get(currentCoder.userId, videoId); | ||
var title = TITLE; | ||
|
||
Session.set('channelSearchQuery', this.params.keyword); | ||
Session.set('currentCoder', currentCoder.userId); | ||
Session.set('currentUsername', currentCoder.username); | ||
Session.set('currentVideo', videoId); | ||
if (currentVideo) { | ||
title = currentVideo.title + ' by ' + currentCoder.name + ' coding with ' + currentVideo.language + title; | ||
} else if (currentCoder.name) { | ||
title = currentCoder.name + title; | ||
} else { | ||
title = 'Coders' + title; | ||
} | ||
data: function () { | ||
return Channels.findOne({_id: this.params.videoId}); | ||
} | ||
}); | ||
|
||
document.title = title; | ||
CoderListController = RouteController.extend({ | ||
template: 'channels', | ||
waitOn: function () { | ||
return Meteor.subscribe('ChannelsWithOwner'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
SearchController = ChannelController.extend({ | ||
SearchController = CoderListController.extend({ | ||
template: 'channels', | ||
onBeforeAction: function () { | ||
var keyword = this.params.keyword; | ||
Session.set('channelSearchQuery', keyword); | ||
document.title = 'Searching for ' + keyword + TITLE; | ||
waitOn: function () { | ||
return Meteor.subscribe('ChannelsSearchWithUsers', this.params.keyword); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.