2023-01-16 23:00:10 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
|
|
2020-03-27 11:35:03 -06:00
|
|
|
Template.notification.events({
|
|
|
|
|
'click .read-status .materialCheckBox'() {
|
|
|
|
|
const update = {};
|
Fix mentions and notifications drawer.
Thanks to xet7 !
Fixes #6062,
fixes #6003,
fixes #5996,
fixes #5720,
fixes #5911,
fixes #5792,
fixes #5163,
fixes #4431,
fixes #4126,
fixes #3363,
fixes #3150
2026-01-14 21:02:10 +02:00
|
|
|
const newReadValue = this.read ? null : Date.now();
|
|
|
|
|
update[`profile.notifications.${this.index}.read`] = newReadValue;
|
|
|
|
|
|
|
|
|
|
Users.update(Meteor.userId(), { $set: update }, (error, result) => {
|
|
|
|
|
if (error) {
|
|
|
|
|
console.error('Error updating notification:', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
|
|
|
|
'click .remove a'() {
|
2023-01-16 23:00:10 +01:00
|
|
|
ReactiveCache.getCurrentUser().removeNotification(this.activityData._id);
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.notification.helpers({
|
|
|
|
|
mode: 'board',
|
|
|
|
|
isOfActivityType(activityId, type) {
|
2023-02-04 00:18:15 +01:00
|
|
|
const activity = ReactiveCache.getActivity(activityId);
|
2020-03-27 11:35:03 -06:00
|
|
|
return activity && activity.activityType === type;
|
|
|
|
|
},
|
|
|
|
|
activityType(activityId) {
|
2023-02-04 00:18:15 +01:00
|
|
|
const activity = ReactiveCache.getActivity(activityId);
|
2020-03-27 11:35:03 -06:00
|
|
|
return activity ? activity.activityType : '';
|
|
|
|
|
},
|
|
|
|
|
activityUser(activityId) {
|
2023-02-04 00:18:15 +01:00
|
|
|
const activity = ReactiveCache.getActivity(activityId);
|
2020-03-27 11:35:03 -06:00
|
|
|
return activity && activity.userId;
|
|
|
|
|
},
|
Fix mentions and notifications drawer.
Thanks to xet7 !
Fixes #6062,
fixes #6003,
fixes #5996,
fixes #5720,
fixes #5911,
fixes #5792,
fixes #5163,
fixes #4431,
fixes #4126,
fixes #3363,
fixes #3150
2026-01-14 21:02:10 +02:00
|
|
|
activityDate() {
|
|
|
|
|
const activity = this.activityData;
|
|
|
|
|
if (!activity || !activity.createdAt) return '';
|
|
|
|
|
|
|
|
|
|
const user = ReactiveCache.getCurrentUser();
|
|
|
|
|
if (!user) return '';
|
|
|
|
|
|
|
|
|
|
const dateFormat = user.getDateFormat ? user.getDateFormat() : 'L';
|
|
|
|
|
const timeFormat = user.getTimeFormat ? user.getTimeFormat() : 'LT';
|
|
|
|
|
|
|
|
|
|
return moment(activity.createdAt).format(`${dateFormat} ${timeFormat}`);
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|