Each user has a gravatar or a profile image if uploaded. A list of rooms is shown (each has 2 parties). It shows the opposite party gravatar/uploaded image and his or her username.
Problem: The Gravatars do not appear but the uploaded images (if uploaded) appear. Gravatar does appear on the user's profile page (with params as the userId).
In console, Meteor.user()
and Meteor.userId()
returns ok. So is the md5hash which returns correct user details.
The user's profile:
profileImg
- uploaded
username
md5hash
emails
Each room contains
owner, receiver, people: [owner, receiver], id //roomId
allRooms.js
Template.allRooms.onCreated(function () {
this.autorun(() => {
this.subscribe('rooms');
this.subscribe('allUsers');
$.cloudinary.config({ cloud_name: "mthh" });
});
});
Template.allRooms.helpers({
chatPerson(){
return this.owner === Meteor.userId() ? Meteor.users.findOne(this.receiver) : Meteor.users.findOne(this.owner);
},
});
allRooms.html
{{#each rooms}}
{{#with chatPerson}} <!-- doesnt work if {{#if chatPerson}} ..nothing shows -->
{{#if profileImg.upload}}
<img src="{{c.url profileImg.upload format=format gravity='faces' mode='thumb' crop='thumb' width=60 height=60}}"> <!-- uploaded pic shows up -->
{{else}}
<div class="avatar" style="background: url({{ avatar 60 chatPerson}}; height: 60px; width: 60px; float:left;"></div> <!-- if no uploaded pic, gravatar doesnt show up but console.log shows user object details and md5hash number -->
{{/if}}
{{/with}}
{{chatPerson.username}} roomId: {{_id}} <!-- shows up -->
{{/each}}
Publication
Meteor.publish('allUsers', () => {
return Meteor.users.find({
fields: { username: 1, emails: 1, profileImg: 1, md5hash: 1}
})
});