From fbd0c0a5156ce328b635b85beb31b66eca57134a Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Tue, 16 Aug 2016 06:43:46 -0400 Subject: [PATCH] fixed #35 --- hourglass/client/profile/profile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js index 5e4a784..cb3a590 100644 --- a/hourglass/client/profile/profile.js +++ b/hourglass/client/profile/profile.js @@ -96,12 +96,15 @@ Template.profile.helpers({ }, avatar() { var dim = window.innerWidth * 1600 / 1920 * 0.16; - if (Meteor.user().profile.avatar !== undefined) { - var pic = Meteor.user().profile.avatar; + var pic = ""; + var userprofile = Meteor.user().profile.avatar; + if (userprofile !== undefined && userprofile !== null) { + pic = Meteor.user().profile.avatar; } else { - var pic = "Avatars/" + (Math.floor(Math.random() * (11 - 1)) + 1).toString() + ".png"; + pic = "Avatars/" + (Math.floor(Math.random() * (11 - 1)) + 1).toString() + ".png"; + console.log(pic); currentprofile = Meteor.user().profile; - currentprofile.avatar = pic + currentprofile.avatar = pic; Meteor.call("editProfile", currentprofile); } return "background-image:url(" + pic + ");background-size:" + dim.toString() + "px " + dim.toString() + "px";