From 252ad3bcc918daa3bee48b18c512cd38e3a7c04e Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Tue, 3 May 2016 10:58:32 +1000 Subject: [PATCH] Possible fix for new message bug --- mail_menu.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/mail_menu.c b/mail_menu.c index 22b0469..36d5077 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -431,7 +431,6 @@ char *editor(int socket, struct user_record *user, char *quote, char *from) { memset(next_line_buffer, 0, 80); if (quote != NULL) { - //wrap(quote, 65); for (i=0;icur_mail_conf]->mail_areas[user->cur_mail_area]->path); break; } else { + all_unread = 0; if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { jlr.LastReadMsg = 0; jlr.HighReadMsg = 0; + all_unread = 1; } JAM_CloseMB(jb); sprintf(buffer, "Read message [1-%d] or N for New: ", msghs->msg_count); @@ -1300,13 +1302,17 @@ int mail_menu(int socket, struct user_record *user) { s_readstring(socket, buffer, 6); if (tolower(buffer[0]) == 'n') { - k = jlr.HighReadMsg; - for (i=0;imsg_count;i++) { - if (msghs->msgs[i]->msg_no == k) { - break; + if (all_unread == 0) { + k = jlr.HighReadMsg; + for (i=0;imsg_count;i++) { + if (msghs->msgs[i]->msg_no == k) { + break; + } } + i += 2; + } else { + i = 1; } - i+=2; } else { i = atoi(buffer); } @@ -1591,9 +1597,11 @@ int mail_menu(int socket, struct user_record *user) { printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); break; } else { + all_unread = 0; if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { jlr.LastReadMsg = 0; jlr.HighReadMsg = 0; + all_unread = 1; } JAM_CloseMB(jb); sprintf(buffer, "Start at message [1-%d] or N for New? ", msghs->msg_count); @@ -1601,13 +1609,17 @@ int mail_menu(int socket, struct user_record *user) { s_readstring(socket, buffer, 6); if (tolower(buffer[0]) == 'n') { - k = jlr.HighReadMsg; - for (i=0;imsg_count;i++) { - if (msghs->msgs[i]->msg_no == k) { - break; + if (all_unread == 0) { + k = jlr.HighReadMsg; + for (i=0;imsg_count;i++) { + if (msghs->msgs[i]->msg_no == k) { + break; + } } + i+=2; + } else { + i = 1; } - i+=2; } else { i = atoi(buffer); if (i <= 0) {