import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveDict } from 'meteor/reactive-dict';

import { Activities } from '../api/activities.js';

import './activity.js';
import './viewProfile.html';

Template.viewProfile.onCreated(function bodyOnCreated() {
    this.state = new ReactiveDict();
    Meteor.subscribe('activities');
    Meteor.subscribe('allUsers');
    Meteor.subscribe('allConnections');
});

Template.viewProfile.helpers({
  data() {
    // console.log(FlowRouter.getParam('_id'));
    user = Meteor.users.findOne({_id : FlowRouter.getParam('_id')});
    // console.log(user);
    return user;
  },
  getPicURL() {
      var ret = "";
      console.log(this);
      console.log(this.picURL);
      if(!this.picURL) {
          ret = "/pix/riley.jpg";
      } else {
          ret = this.picURL;
      }
      return ret;
  }
});

Template.viewProfile.events({
});

@@ -744,17 +744,97 @@
 his.
-picURL
+_id);%0A      var profId = this._id;%0A      var prof = Activities.findOne(%7B_id : profId%7D
 );%0A
+%0A
     
@@ -842,23 +842,145 @@
  if(
-!this.picURL) %7B
+prof) %7B%0A          if(prof.picURL) %7B%0A              ret = prof.picURL;%0A          %7D else %7B%0A              ret = %22/pix/riley.jpg%22;%0A          %7D
 %0A   
@@ -1045,19 +1045,24 @@
 t = 
-this.picURL
+%22/pix/riley.jpg%22
 ;%0A  

fix bugs