[FIX] calendar: multiple notifications for an event
Before this commit, when an event have multiples notifications, if the first notification is not ack when the second notification is shown, not only two are visualized but multiples notifications are raised. Now, only the correct number of notifications are shown. opw-2070852 closes odoo/odoo#39909 X-original-commit: 8ab0bfeaa7b6c3e1642064d123197b1cba74355d Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com>
This commit is contained in:
committed by
fw-bot
co-authored by
Aaron Bohy
Lucas Perais
parent
daa693fe93
commit
c79311d00e
@@ -454,6 +454,7 @@ class AlarmManager(models.AbstractModel):
|
||||
delta = delta.seconds + delta.days * 3600 * 24
|
||||
|
||||
return {
|
||||
'alarm_id': alarm.id,
|
||||
'event_id': meeting.id,
|
||||
'title': meeting.name,
|
||||
'message': message,
|
||||
|
||||
@@ -38,12 +38,12 @@ var CalendarNotification = Notification.extend({
|
||||
},
|
||||
|
||||
'click .link2recall': function() {
|
||||
this.destroy(true);
|
||||
this.close();
|
||||
},
|
||||
|
||||
'click .link2showed': function() {
|
||||
this._rpc({route: '/calendar/notify_ack'})
|
||||
.then(this.destroy.bind(this), this.destroy.bind(this));
|
||||
.then(this.close.bind(this, false), this.close.bind(this, false));
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -57,22 +57,25 @@ WebClient.include({
|
||||
// Clear previously set timeouts and destroy currently displayed calendar notifications
|
||||
clearTimeout(this.get_next_calendar_notif_timeout);
|
||||
_.each(this.calendar_notif_timeouts, clearTimeout);
|
||||
_.each(this.calendar_notif, function (notificationID) {
|
||||
self.call('notification', 'close', notificationID, true);
|
||||
});
|
||||
this.calendar_notif_timeouts = {};
|
||||
this.calendar_notif = {};
|
||||
|
||||
// For each notification, set a timeout to display it
|
||||
_.each(notifications, function(notif) {
|
||||
self.calendar_notif_timeouts[notif.event_id] = setTimeout(function() {
|
||||
var key = notif.event_id + ',' + notif.alarm_id;
|
||||
if (key in self.calendar_notif) {
|
||||
return;
|
||||
}
|
||||
self.calendar_notif_timeouts[key] = setTimeout(function () {
|
||||
var notificationID = self.call('notification', 'notify', {
|
||||
Notification: CalendarNotification,
|
||||
title: notif.title,
|
||||
message: notif.message,
|
||||
eventID: notif.event_id,
|
||||
onClose: function () {
|
||||
delete self.calendar_notif[key];
|
||||
},
|
||||
});
|
||||
self.calendar_notif[notif.event_id] = notificationID;
|
||||
self.calendar_notif[key] = notificationID;
|
||||
}, notif.timer * 1000);
|
||||
last_notif_timer = Math.max(last_notif_timer, notif.timer);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user