reduce possible unseen counter on folderlabel on preview and mail-open; no server roundtrip, just grab the label, extract the counter, reduce by one, set the label

This commit is contained in:
Klaus Leithoff 2014-02-07 14:34:04 +00:00
parent ca334ad13b
commit 08e01e54cf

View File

@ -247,6 +247,20 @@ app.classes.mail = AppJS.extend(
egw(h).ready(function() { egw(h).ready(function() {
h.document.title = subject; h.document.title = subject;
}); });
// THE FOLLOWING IS PROBABLY NOT NEEDED, AS THE UNEVITABLE PREVIEW IS HANDLING THE COUNTER ISSUE
var messages = {};
messages['msg'] = [_id];
// When body is requested, mail is marked as read by the mail server. Update UI to match.
if (typeof dataElem != 'undefined' && typeof dataElem.data != 'undefined' && typeof dataElem.data.flags != 'undefined' && typeof dataElem.data.flags.read != 'undefined') dataElem.data.flags.read = 'read';
if (typeof dataElem != 'undefined' && typeof dataElem.data != 'undefined' && (dataElem.data.class.indexOf('unseen') >= 0 || dataElem.data.class.indexOf('recent') >= 0))
{
this.mail_removeRowClass(messages,'recent');
this.mail_removeRowClass(messages,'unseen');
// reduce counter without server roundtrip
this.mail_reduceCounterWithoutServerRoundtrip();
// not needed, as an explizit read flags the message as seen anyhow
//egw.jsonq('mail.mail_ui.ajax_flagMessages',['read', messages, false]);
}
}, },
/** /**
@ -699,9 +713,14 @@ app.classes.mail = AppJS.extend(
// When body is requested, mail is marked as read by the mail server. Update UI to match. // When body is requested, mail is marked as read by the mail server. Update UI to match.
if (typeof dataElem != 'undefined' && typeof dataElem.data != 'undefined' && typeof dataElem.data.flags != 'undefined' && typeof dataElem.data.flags.read != 'undefined') dataElem.data.flags.read = 'read'; if (typeof dataElem != 'undefined' && typeof dataElem.data != 'undefined' && typeof dataElem.data.flags != 'undefined' && typeof dataElem.data.flags.read != 'undefined') dataElem.data.flags.read = 'read';
if (typeof dataElem != 'undefined' && typeof dataElem.data != 'undefined' && (dataElem.data.class.indexOf('unseen') >= 0 || dataElem.data.class.indexOf('recent') >= 0))
{
this.mail_removeRowClass(messages,'recent'); this.mail_removeRowClass(messages,'recent');
this.mail_removeRowClass(messages,'unseen'); this.mail_removeRowClass(messages,'unseen');
// reduce counter without server roundtrip
this.mail_reduceCounterWithoutServerRoundtrip();
egw.jsonq('mail.mail_ui.ajax_flagMessages',['read', messages, false]); egw.jsonq('mail.mail_ui.ajax_flagMessages',['read', messages, false]);
}
// Pre-load next email already so user gets it faster // Pre-load next email already so user gets it faster
// Browser will cache the file for us // Browser will cache the file for us
/* /*
@ -1009,6 +1028,24 @@ app.classes.mail = AppJS.extend(
if (calledFromPopup && this.mail_isMainWindow==false) window.close(); if (calledFromPopup && this.mail_isMainWindow==false) window.close();
}, },
/**
* function to find (and reduce) unseen count from folder-name
*/
mail_reduceCounterWithoutServerRoundtrip: function()
{
ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var _foldernode = ftree.getSelectedNode();
var counter = _foldernode.label.match(this._unseen_regexp);
var icounter = parseInt(counter[0].replace(' (','').replace(')',''));
if (icounter>0)
{
var newcounter = icounter-1;
if (newcounter>0) _foldernode.label = _foldernode.label.replace(' ('+String(icounter)+')',' ('+String(newcounter)+')');
if (newcounter==0) _foldernode.label = _foldernode.label.replace(' ('+String(icounter)+')','');
ftree.setLabel(_foldernode.id,_foldernode.label);
}
},
/** /**
* Regular expression to find (and remove) unseen count from folder-name * Regular expression to find (and remove) unseen count from folder-name
*/ */