Fix for when a user only has 1 new message to them

This commit is contained in:
Deon George 2022-12-16 23:23:28 +11:00
parent ab91db2efa
commit ef4453b77b

View File

@ -244,28 +244,29 @@ PageFrame.prototype.loadMessage = function(page) {
// if this message is to the user, and the msg number > scan_ptr and it is the next message on the user's new mail list // if this message is to the user, and the msg number > scan_ptr and it is the next message on the user's new mail list
var newmsgs = area.newMsgsToMe(); var newmsgs = area.newMsgsToMe();
var next; var next;
log(LOG_DEBUG,'User has: '+newmsgs.length+' msgs to read to ME'); log(LOG_DEBUG,'User has: '+newmsgs.length-1+' msgs to read to ME');
if (newmsgs.length) { if (newmsgs.length) {
next = newmsgs[1]; next = newmsgs[1];
log(LOG_DEBUG,'- NEXT is: '+next.tags+', this is: '+msg.tags); //log(LOG_DEBUG,'- NEXT is: '+next.tags+', this is: '+msg.tags);
if (next.tags === msg.tags) { if (next && (next.tags === msg.tags)) {
log(LOG_DEBUG,'- Updating scan_ptr to: '+next.number); log(LOG_DEBUG,'- Updating scan_ptr to: '+next.number);
stats.scan_ptr = next.number; stats.scan_ptr = next.number;
} }
// Last message // Last message
next = newmsgs[0]; next = newmsgs[0];
log(LOG_DEBUG,'- LAST TO ME is: '+next.tags);
if (next !== undefined) { if (next !== undefined) {
log(LOG_DEBUG,'- LAST TO ME is: '+next.tags);
this.key[1] = area.page(next.tags); this.key[1] = area.page(next.tags);
} }
// Next new message // Next new message
next = newmsgs[2]; next = newmsgs[2];
log(LOG_DEBUG,'- NEXT TO ME is: '+next.tags); if (next !== undefined) {
if (next !== undefined) log(LOG_DEBUG,'- NEXT TO ME is: '+next.tags);
this.key[2] = area.page(next.tags); this.key[2] = area.page(next.tags);
}
} }
// if this message is the next message, update last_read // if this message is the next message, update last_read