* \param MatchMSet MSet we want to flag
* \param FlagToSet Flag to set on each BasicMsgStruct->Flags if in MSet
*/
-void SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reverse)
+long SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reverse)
{
const char *HashKey;
long HKLen;
+ long count = 0;
HashPos *at;
void *vMsg;
message_summary *Msg;
Msg = (message_summary*) vMsg;
if (Reverse && IsInMSetList(MatchMSet, Msg->msgnum)) {
Msg->Flags = Msg->Flags | FlagToSet;
+ count++;
}
else if (!Reverse && !IsInMSetList(MatchMSet, Msg->msgnum)) {
Msg->Flags = Msg->Flags | FlagToSet;
+ count++;
}
}
DeleteHashPos(&at);
+ return count;
}
-void load_seen_flags(void)
+long load_seen_flags(void)
{
+ long count = 0;
StrBuf *OldMsg;
wcsession *WCC = WC;
MSet *MatchMSet;
}
else {
FreeStrBuf(&OldMsg);
- return;
+ return 0;
}
if (ParseMSet(&MatchMSet, OldMsg))
{
- SetFlagsFromMSet(WCC->summ, MatchMSet, MSGFLAG_READ, 0);
+ count = SetFlagsFromMSet(WCC->summ, MatchMSet, MSGFLAG_READ, 0);
}
DeleteMSet(&MatchMSet);
FreeStrBuf(&OldMsg);
+ return count;
}
extern readloop_struct rlid[];
Stat.startmsg = 0;
}
- if (Stat.load_seen) load_seen_flags();
+ if (Stat.load_seen) Stat.numNewmsgs = load_seen_flags();
/*
* Print any inforation above the message list...
Foo = NewStrBuf ();
StrBufPrintf(Foo, "%ld", Stat.nummsgs);
- PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo));
+ PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo)); // keep Foo!
+
+ StrBufPrintf(Foo, "%ld", Stat.numNewmsgs);
+ PutBstr(HKEY("__READLOOP:NEWMSGS"), NewStrBufDup(Foo)); // keep Foo!
+
StrBufPrintf(Foo, "%ld", Stat.startmsg);
- PutBstr(HKEY("__READLOOP:STARTMSG"), Foo);
+ PutBstr(HKEY("__READLOOP:STARTMSG"), Foo); // store Foo elsewhere, descope it here.
}
/*
long startmsg; /* which is the start message? */
long nummsgs; /* How many messages are available to your view? */
+ long numNewmsgs; /* if you load the seen-status, this is the count of them. */
long num_displayed; /* counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
long lowest_found; /* smallest Message ID found; */
var nummsgs = 0;
var startmsg = 0;
+var newmsgs = 0;
+
+function refreshMessageCounter() {
+ var templStr = document.getElementById("nummsgs_template").innerHTML;
+ templStr = templStr.replace(/UNREADMSGS/, newmsgs);
+ templStr = templStr.replace(/TOTALMSGS/, nummsgs);
+ document.getElementById("nummsgs").innerHTML = templStr;
+}
function createMessageView() {
message_view = document.getElementById("message_list_body");
alert("Message loading failed");
}
nummsgs = data['nummsgs'];
+ newmsgs = data['newmsgs'];
msgs = data['msgs'];
var length = msgs.length;
rowArray = new Array(length); // store so they can be sorted
loadingMsg.parentNode.removeChild(loadingMsg);
}
sizePreviewPane();
+ refreshMessageCounter();
}
function resortAndDisplay(sortMode) {
WCLog("Begin resortAndDisplay");
var msgId = parent.getAttribute("citadel:msgid");
var is_shift_pressed = event.shiftKey;
var is_ctrl_pressed = event.ctrlKey;
+ var rowclass = parent.getAttribute("class");
+ var msgUnseen = rowclass.search("new_message") >= 0;
/* debugging
str = '.';
document.getElementById("preview_pane").innerHTML = "";
new Ajax.Updater('preview_pane', 'msg/'+msgId, {method: 'get'});
markRow(parent);
- var p = encodeURI('g_cmd=SEEN ' + msgId + '|1');
- new Ajax.Request('ajax_servcmd', {
+
+ if (msgUnseen) {
+ var p = encodeURI('g_cmd=SEEN ' + msgId + '|1');
+ new Ajax.Request('ajax_servcmd', {
method: 'post',
parameters: p,
onComplete: CtdlMarkRowAsRead(parent)
- });
+ });
+ }
// If the shift key modifier is used, mark a range...
} else if (event.button != 2 && is_shift_pressed) {
if (originalMarkedRow == null) {
var classes = rowElement.className;
classes = classes.replace("new_message","");
rowElement.className = classes;
+ newmsgs--;
+ refreshMessageCounter();
}
function ApplySort(event) {
var target = event.target;
function deleteAllMarkedRows() {
for(msgId in currentlyMarkedRows) {
var row = currentlyMarkedRows[msgId];
+ var rowclass = row.getAttribute("class");
+ var msgUnseen = rowclass.search("new_message") >= 0;
+
var rowArrayId = row.getAttribute("citadel:ctdlrowid");
row.parentNode.removeChild(row);
delete currentlyMarkedRows[msgId];
delete msgs[rowArrayId];
+ if (msgUnseen)
+ newmsgs--;
+ nummsgs--;
}
// Now we have to reconstruct rowarray as the array length has changed */
var newMsgs = new Array(msgs.length-1);
}
msgs = newMsgs;
resortAndDisplay(null);
+ refreshMessageCounter();
}
function deleteAllSelectedMessages() {
var mvCommand = "";
{ "nummsgs": <?BSTR("__READLOOP:TOTALMSGS")>,
+"newmsgs": <?BSTR("__READLOOP:NEWMSGS")>,
"startmsg": <?BSTR("__READLOOP:STARTMSG")>,
"roomname": "<?THISROOM:NAME("J")>",
"msgs": [ <?ITERATE("MAIL:SUMM:MSGS", ="mailsummary_json_section",
<!-- start roombanner.html -->
<div class="banner" id="room_banner">
+ <div id="nummsgs_template" class="hidden">UNREADMSGS <?_("new of")> TOTALMSGS <?_("messages")></div>
<table border=0><tr>
<td><?=("room_view_picture")></td>