Fix notifications with same id but no links are not getting grouped together

This commit is contained in:
Hadi Nategh 2018-07-23 16:24:47 +02:00
parent 5a9804ed86
commit c5e902926b
4 changed files with 11 additions and 8 deletions

View File

@ -804,6 +804,7 @@ abstract class Tracking
$notification->set_sender($sender); $notification->set_sender($sender);
$notification->set_subject($subject); $notification->set_subject($subject);
$notification->set_links(array($link)); $notification->set_links(array($link));
$notification->set_popupdata($link['app'], $link);
if ($attachments && is_array($attachments)) if ($attachments && is_array($attachments))
{ {
$notification->set_attachments($attachments); $notification->set_attachments($attachments);

View File

@ -1098,7 +1098,8 @@ class calendar_boupdate extends calendar_bo
$notification->set_popupdata('calendar', array( $notification->set_popupdata('calendar', array(
'event_id' => $event['id'], 'event_id' => $event['id'],
'user_id' => $userid, 'user_id' => $userid,
'type' => $m_type 'type' => $m_type,
'id' => $event['id']
)); ));
} }
if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type));

View File

@ -201,7 +201,7 @@ class notifications_ajax {
'created' => Api\DateTime::to($notification['notify_created']), 'created' => Api\DateTime::to($notification['notify_created']),
'current' => new DateTime(), 'current' => new DateTime(),
'actions' => is_array($actions)?$actions:NULL, 'actions' => is_array($actions)?$actions:NULL,
'extra_data' => $data['data'] 'extra_data' => ($data['data'] ? $data['data'] : array())
); );
} }

View File

@ -602,10 +602,10 @@
notifymessages = {}; notifymessages = {};
for (var i=0; i < _rawData.length; i++) for (var i=0; i < _rawData.length; i++)
{ {
var data = this.getData(_rawData[i]['message']); var data = this.getData(_rawData[i]['message'], _rawData[i]['extra_data']);
var parent; var parent;
if ((parent = this.findParent(data['id'], data['app'])) if ((parent = this.findParent(data['id'], data['app']))
&& !(_rawData[i]['extra_data'] && typeof _rawData[i]['extra_data']['egw_pr_notify'] == 'undefined')) && typeof _rawData[i]['extra_data']['egw_pr_notify'] == 'undefined')
{ {
if (parent == _rawData[i]['id']) continue; if (parent == _rawData[i]['id']) continue;
if (!notifymessages[parent]['children']) notifymessages[parent] = jQuery.extend(notifymessages[parent], {children:{}}); if (!notifymessages[parent]['children']) notifymessages[parent] = jQuery.extend(notifymessages[parent], {children:{}});
@ -617,7 +617,7 @@
current: _rawData[i]['current'], current: _rawData[i]['current'],
extra_data: _rawData[i]['extra_data'] extra_data: _rawData[i]['extra_data']
}; };
if (_rawData[i]['actions'] && _rawData[i]['actions'].length > 0) notifymessages[parent]['children'][_rawData[i]]['data']['actions'] = _rawData[i]['actions']; if (_rawData[i]['actions'] && _rawData[i]['actions'].length > 0) notifymessages[parent]['children'][_rawData[i]['id']]['data']['actions'] = _rawData[i]['actions'];
continue; continue;
} }
@ -698,15 +698,16 @@
* @param {type} _message * @param {type} _message
* @returns {notificationajaxpopup_L15.notifications.prototype.getData.data} * @returns {notificationajaxpopup_L15.notifications.prototype.getData.data}
*/ */
notifications.prototype.getData = function (_message) { notifications.prototype.getData = function (_message, _extra_data) {
var dom = jQuery(document.createElement('div')).html(_message);; var dom = jQuery(document.createElement('div')).html(_message);
var extra_data = _extra_data || {};
var link = dom.find('div[data-id],div[data-url]'); var link = dom.find('div[data-id],div[data-url]');
var data = { var data = {
message: dom.text(), message: dom.text(),
title: link.text(), title: link.text(),
icon: link.find('img').attr('src') icon: link.find('img').attr('src')
}; };
jQuery.extend(data,link.data()); jQuery.extend(data,link.data(), extra_data);
return typeof data == 'object'? data: {}; return typeof data == 'object'? data: {};
}; };