chat_message.js 675 B

123456789101112131415161718192021222324252627282930313233
  1. Template.chat_message.helpers({
  2. sender: function () {
  3. const me = Meteor.userId();
  4. let result;
  5. if (this.message.sender === me) {
  6. if (me) {
  7. result = Meteor.user();
  8. }
  9. else {
  10. result = {
  11. profile: {
  12. username: "Anonymous",
  13. avatar: "anonymous.png"
  14. }
  15. };
  16. }
  17. }
  18. else if (this.message.sender === this.other._id) {
  19. result = this.other;
  20. }
  21. else {
  22. result = {
  23. profile: {
  24. username: `Unknown user ${this.message.sender}.`,
  25. avatar: "ghost.png"
  26. }
  27. };
  28. }
  29. console.log("returning", result);
  30. return result;
  31. }
  32. });