Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let template = Template.instance()
- this.autorun(() => {
- let matchid = Router.current().params.id;
- let match = Matches.findOne({_id: matchid});
- if (match){
- let user = JSON.parse(localStorage.getItem('rau-user'));
- if(user) {
- //Set Users Team
- let foundhome = user.teams.findIndex( obj => obj._id === match.homeTeam._id )
- let foundaway = user.teams.findIndex( obj => obj._id === match.awayTeam._id )
- let userteams = [];
- if (foundhome != -1 && foundaway != -1) {
- // Team manager for both teams
- userteams.push(user.teams[foundhome]);
- userteams.push(user.teams[foundaway]);
- }
- else if(foundhome != -1) {
- userteams.push(user.teams[foundhome]);
- template.userteam.set(user.teams[foundhome]);
- }
- else {
- userteams.push(user.teams[foundaway]);
- template.userteam.set(user.teams[foundaway]);
- }
- template.userteams.set(userteams);
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement