Fix notifications stalling login

This commit is contained in:
Hadi Nategh 2020-07-29 12:55:08 +02:00
parent bd8b99f8c1
commit 631587eab1
3 changed files with 30 additions and 21 deletions

View File

@ -270,7 +270,7 @@
setActiveApp: function(_app) setActiveApp: function(_app)
{ {
var result = this._super.apply(this, arguments); var result = this._super.apply(this, arguments);
this.notifyAppTab(_app.appName , true); this.notifyAppTab(_app.appName , 0);
if (_app == _app.parentFw.activeApp) if (_app == _app.parentFw.activeApp)
{ {
//Set the sidebox width if a application specific sidebox width is set //Set the sidebox width if a application specific sidebox width is set
@ -513,15 +513,15 @@
* Notify tab * Notify tab
* *
* @param {string} _appname * @param {string} _appname
* @param {boolean} _clear reset notification if set to true * @param {int} _value to set as notification, 0 will reset notification
*/ */
notifyAppTab: function(_appname, _clear) notifyAppTab: function(_appname, _value)
{ {
var tab = this.tabsUi.getTab(_appname); var tab = this.tabsUi.getTab(_appname);
// do not set tab's notification if it's the active tab // do not set tab's notification if it's the active tab
if (tab && (this.activeApp.appName != _appname || _clear)) if (tab && (this.activeApp.appName != _appname || _value == 0))
{ {
this.tabsUi.getTab(_appname).setNotification(_clear); this.tabsUi.getTab(_appname).setNotification(_value);
} }
} }
}); });

View File

@ -418,11 +418,12 @@ function egw_fw_ui_tab(_parent, _contHeaderDiv, _contDiv, _icon, _callback,
/** /**
* set notification * set notification
* *
* @param {boolean} _off if set to true the notification gets reset * @param {int} _value if set to 0 the notification gets reset if nothing set
* it will increase the notification value by one
*/ */
egw_fw_ui_tab.prototype.setNotification = function(_off) egw_fw_ui_tab.prototype.setNotification = function(_value)
{ {
this.notification = _off ? 0 : this.notification+1; this.notification = typeof _value != 'undefined' ? _value : this.notification+1;
jQuery(this.notificationDiv).text(this.notification).toggle(this.notification > 0); jQuery(this.notificationDiv).text(this.notification).toggle(this.notification > 0);
}; };

View File

@ -218,16 +218,16 @@
for(var index in indexes) for(var index in indexes)
{ {
var id = indexes[index]; var id = indexes[index];
if (this.filter && notifymessages[id]['data']['app'] != this.filter) continue;
var $message, $mark, $delete, $inner_container, $nav_prev, $nav_next, var $message, $mark, $delete, $inner_container, $nav_prev, $nav_next,
$more_info, $top_toolbar, $open_entry, $date, $collapse; $more_info, $top_toolbar, $open_entry, $date, $collapse;
var message_id = 'egwpopup_message_'+id; var message_id = 'egwpopup_message_'+id;
var time_label = this.getTimeLabel(notifymessages[id]['created'], notifymessages[id]['current']); var time_label = this.getTimeLabel(notifymessages[id]['created'], notifymessages[id]['current']);
if (jQuery('#'+message_id,$egwpopup_list).length > 0) if (jQuery('#'+message_id,$egwpopup_list).length > 0)
{ {
this.update_message_status(id, notifymessages[id]['status']); this.update_message_status(id, notifymessages[id]['status'], true);
continue; continue;
} }
if (this.filter && notifymessages[id]['data']['app'] != this.filter) continue;
// set the time labels on // set the time labels on
switch (time_label) switch (time_label)
{ {
@ -352,7 +352,7 @@
$egwpopup_list.append($message); $egwpopup_list.append($message);
// bind click handler after the message container is attached // bind click handler after the message container is attached
$message.click(jQuery.proxy(this.clickOnMessage, this,[$message])); $message.click(jQuery.proxy(this.clickOnMessage, this,[$message]));
this.update_message_status(id, notifymessages[id]['status']); this.update_message_status(id, notifymessages[id]['status'], true);
if (notifymessages[id]['extra_data'] if (notifymessages[id]['extra_data']
&& !notifymessages[id]['status'] && !notifymessages[id]['status']
&& notifymessages[id]['extra_data']['egw_pr_notify']) && notifymessages[id]['extra_data']['egw_pr_notify'])
@ -543,7 +543,7 @@
} }
}; };
notifications.prototype.update_message_status = function (_id, _status) notifications.prototype.update_message_status = function (_id, _status, _noCounterUpdate)
{ {
var $egwpopup_message = jQuery('#egwpopup_message_'+_id); var $egwpopup_message = jQuery('#egwpopup_message_'+_id);
notifymessages[_id]['status'] = _status; notifymessages[_id]['status'] = _status;
@ -560,7 +560,7 @@
break; break;
} }
} }
this.counterUpdate(); if (!_noCounterUpdate) this.counterUpdate();
}; };
notifications.prototype.delete_all = function () { notifications.prototype.delete_all = function () {
@ -784,6 +784,7 @@
{ {
this.filter = _appname; this.filter = _appname;
this.toggle(); this.toggle();
this.display();
return true; return true;
} }
} }
@ -799,7 +800,7 @@
var $egwpopup = jQuery('#egwpopup'); var $egwpopup = jQuery('#egwpopup');
var $body = jQuery('body'); var $body = jQuery('body');
var $counter = jQuery('#topmenu_info_notifications'); var $counter = jQuery('#topmenu_info_notifications');
this.display(); if (!_stat) this.display();
var self = this; var self = this;
if (!$egwpopup.is(":visible")) if (!$egwpopup.is(":visible"))
{ {
@ -833,23 +834,30 @@
{ {
var $topmenu_info_notifications = jQuery('#topmenu_info_notifications'); var $topmenu_info_notifications = jQuery('#topmenu_info_notifications');
var counter = 0; var counter = 0;
var apps = {};
for(var j in notifymessages)
{
//reset all tab notifications
framework.notifyAppTab(notifymessages[j]['extra_data']['app'], true);
}
for (var id in notifymessages) for (var id in notifymessages)
{ {
if (typeof apps[notifymessages[id]['extra_data']['app']] == 'undefined')
{
apps[notifymessages[id]['extra_data']['app']] = 0;
}
if (notifymessages[id]['status'] != 'SEEN') if (notifymessages[id]['status'] != 'SEEN')
{ {
counter++; counter++;
framework.notifyAppTab(notifymessages[id]['extra_data']['app']); if (typeof apps[notifymessages[id]['extra_data']['app']] != 'undefined')
{
apps[notifymessages[id]['extra_data']['app']] +=1;
}
} }
} }
if (counter > 0) if (counter > 0)
{ {
for (var app in apps)
{
framework.notifyAppTab(app, apps[app]);
}
$topmenu_info_notifications.addClass('egwpopup_notify'); $topmenu_info_notifications.addClass('egwpopup_notify');
framework.topmenu_info_notify('notifications', true, counter,egw.lang('You have %1 unread notifications', counter)); framework.topmenu_info_notify('notifications', true, counter,egw.lang('You have %1 unread notifications', counter));
} }