Advertisement
Guest User

Untitled

a guest
May 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. let template = Template.instance()
  2. this.autorun(() => {
  3. let matchid = Router.current().params.id;
  4. let match = Matches.findOne({_id: matchid});
  5. if (match){
  6. let user = JSON.parse(localStorage.getItem('rau-user'));
  7. if(user) {
  8. //Set Users Team
  9. let foundhome = user.teams.findIndex( obj => obj._id === match.homeTeam._id )
  10. let foundaway = user.teams.findIndex( obj => obj._id === match.awayTeam._id )
  11.  
  12. let userteams = [];
  13. if (foundhome != -1 && foundaway != -1) {
  14. // Team manager for both teams
  15. userteams.push(user.teams[foundhome]);
  16. userteams.push(user.teams[foundaway]);
  17. }
  18. else if(foundhome != -1) {
  19. userteams.push(user.teams[foundhome]);
  20. template.userteam.set(user.teams[foundhome]);
  21. }
  22. else {
  23. userteams.push(user.teams[foundaway]);
  24. template.userteam.set(user.teams[foundaway]);
  25. }
  26. template.userteams.set(userteams);
  27. }
  28. }
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement