|
@@ -161,19 +161,19 @@ function Station(type) {
|
|
Playlists.update({type: type}, {$push: {songs: default_song.mid}});
|
|
Playlists.update({type: type}, {$push: {songs: default_song.mid}});
|
|
}
|
|
}
|
|
Meteor.publish(type, function () {
|
|
Meteor.publish(type, function () {
|
|
- var userId = this.userId;
|
|
|
|
- Meteor.thisIsA = this;
|
|
|
|
- var username = Meteor.users.findOne(userId).profile.username;
|
|
|
|
- Rooms.update({type: type}, {$push: {userList: username}});
|
|
|
|
- this.onStop(function() {
|
|
|
|
- var list = Rooms.findOne({type: type}).userList;
|
|
|
|
- var index = list.indexOf(username);
|
|
|
|
- if (index >= 0) {
|
|
|
|
- list.splice( index, 1 );
|
|
|
|
- }
|
|
|
|
|
|
+ var username = Meteor.users.findOne(this.userId).profile.username;
|
|
|
|
+ if (username !== undefined) {
|
|
|
|
+ Rooms.update({type: type}, {$push: {userList: username}});
|
|
|
|
+ this.onStop(function() {
|
|
|
|
+ var list = Rooms.findOne({type: type}).userList;
|
|
|
|
+ var index = list.indexOf(username);
|
|
|
|
+ if (index >= 0) {
|
|
|
|
+ list.splice( index, 1 );
|
|
|
|
+ }
|
|
|
|
|
|
- Rooms.update({type: type}, {$set: {userList: list}});
|
|
|
|
- });
|
|
|
|
|
|
+ Rooms.update({type: type}, {$set: {userList: list}});
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return undefined;
|
|
return undefined;
|
|
});
|
|
});
|
|
var self = this;
|
|
var self = this;
|