notificationsDrawer.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { toggleNotificationsDrawer } from './notifications.js';
  2. Template.notificationsDrawer.onCreated(function() {
  3. Meteor.subscribe('notificationActivities');
  4. Meteor.subscribe('notificationCards');
  5. Meteor.subscribe('notificationUsers');
  6. Meteor.subscribe('notificationsAttachments');
  7. Meteor.subscribe('notificationChecklistItems');
  8. Meteor.subscribe('notificationChecklists');
  9. Meteor.subscribe('notificationComments');
  10. Meteor.subscribe('notificationLists');
  11. Meteor.subscribe('notificationSwimlanes');
  12. });
  13. Template.notificationsDrawer.helpers({
  14. transformedProfile() {
  15. return Users.findOne(Meteor.userId());
  16. },
  17. });
  18. Template.notificationsDrawer.events({
  19. 'click .all-read'() {
  20. const notifications = Meteor.user().profile.notifications;
  21. for (const index in notifications) {
  22. if (notifications.hasOwnProperty(index) && !notifications[index].read) {
  23. const update = {};
  24. update[`profile.notifications.${index}.read`] = Date.now();
  25. Users.update(Meteor.userId(), { $set: update });
  26. }
  27. }
  28. },
  29. 'click .close'() {
  30. toggleNotificationsDrawer();
  31. },
  32. 'click .toggle-read'() {
  33. Session.set('showReadNotifications', !Session.get('showReadNotifications'));
  34. },
  35. });