mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-27 05:11:41 +02:00
* Notifications: Some performance optimizations
This commit is contained in:
parent
be06f1fbef
commit
ddd8ce2202
@ -16,6 +16,7 @@
|
|||||||
{
|
{
|
||||||
var notifymessages = {};
|
var notifymessages = {};
|
||||||
|
|
||||||
|
var _currentRawData = [];
|
||||||
/**
|
/**
|
||||||
* time range label today
|
* time range label today
|
||||||
* @type Number
|
* @type Number
|
||||||
@ -262,6 +263,7 @@
|
|||||||
{
|
{
|
||||||
for (var c in notifymessages[id]['children'])
|
for (var c in notifymessages[id]['children'])
|
||||||
{
|
{
|
||||||
|
if (Object.keys(notifymessages[id]['children']).indexOf(c) < Object.keys(notifymessages[id]['children']).length-2) continue;
|
||||||
$inner_container[0].innerHTML += notifymessages[id]['children'][c]['message'];
|
$inner_container[0].innerHTML += notifymessages[id]['children'][c]['message'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,6 +663,11 @@
|
|||||||
notifications.prototype.append = function(_rawData, _browser_notify) {
|
notifications.prototype.append = function(_rawData, _browser_notify) {
|
||||||
|
|
||||||
var hasUnseen = [];
|
var hasUnseen = [];
|
||||||
|
// Dont process the data if they're the same as it could get very expensive to
|
||||||
|
// proccess html their content.
|
||||||
|
if (_currentRawData.length>0 && _currentRawData.length == _rawData.length) return;
|
||||||
|
_currentRawData = _rawData;
|
||||||
|
let old_notifymessages = notifymessages;
|
||||||
notifymessages = {};
|
notifymessages = {};
|
||||||
var browser_notify = _browser_notify || this.check_browser_notify();
|
var browser_notify = _browser_notify || this.check_browser_notify();
|
||||||
for (var i=0; i < _rawData.length; i++)
|
for (var i=0; i < _rawData.length; i++)
|
||||||
@ -737,6 +744,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
let egwpopup = document.getElementById('egwpopup');
|
||||||
switch(egw.preference('egwpopup_verbosity', 'notifications'))
|
switch(egw.preference('egwpopup_verbosity', 'notifications'))
|
||||||
{
|
{
|
||||||
case 'low':
|
case 'low':
|
||||||
@ -748,10 +756,17 @@
|
|||||||
alert(egw.lang('EGroupware has notifications for you'));
|
alert(egw.lang('EGroupware has notifications for you'));
|
||||||
egw.json("notifications.notifications_ajax.update_status", [hasUnseen, 'DISPLAYED']).sendRequest();
|
egw.json("notifications.notifications_ajax.update_status", [hasUnseen, 'DISPLAYED']).sendRequest();
|
||||||
}
|
}
|
||||||
this.display();
|
if (egwpopup.style.display != 'none') this.display();
|
||||||
break;
|
break;
|
||||||
case 'medium':
|
case 'medium':
|
||||||
|
if (egwpopup.style.display != 'none' && Object.keys(old_notifymessages).length != Object.keys(notifymessages).length)
|
||||||
|
{
|
||||||
this.display();
|
this.display();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.counterUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -763,7 +778,9 @@
|
|||||||
* @returns {notificationajaxpopup_L15.notifications.prototype.getData.data}
|
* @returns {notificationajaxpopup_L15.notifications.prototype.getData.data}
|
||||||
*/
|
*/
|
||||||
notifications.prototype.getData = function (_message, _extra_data) {
|
notifications.prototype.getData = function (_message, _extra_data) {
|
||||||
var dom = jQuery(document.createElement('div')).html(_message);
|
var parser = new DOMParser();
|
||||||
|
var dom = jQuery(parser.parseFromString(_message, 'text/html'));
|
||||||
|
|
||||||
var extra_data = _extra_data || {};
|
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 = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user