* with it, go get commit dcf99fe61379b78436c387ea3f89ebfd4ffaf635 of
* bbsview_renderer.c and have fun.
*
- * Copyright (c) 1996-2010 by the citadel.org team
+ * Copyright (c) 1996-2011 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License as
const StrBuf *Mime;
int start_index = 0;
int end_index = 0;
+ int go_to_the_very_end = 0;
if (Stat->nummsgs > 0) {
syslog(9, "sorting %d messages\n", BBS->num_msgs);
*/
if (BBS->requested_page == (-3)) {
if (BBS->num_msgs == 0) {
+ /*
+ * The room is empty; just start at the top and leave it there.
+ */
BBS->requested_page = 0;
}
+ else if (
+ (BBS->num_msgs > 0)
+ && (BBS->lastseen <= BBS->msgs[0])
+ ) {
+ /*
+ * All messages are new; this is probably the user's first visit to the room,
+ * so start at the last page instead of showing ancient history.
+ */
+ BBS->requested_page = BBS->num_pages - 1;
+ go_to_the_very_end = 1;
+ }
else {
+ /*
+ * Some messages are old and some are new. Go to the start of new messages.
+ */
for (i=0; i<BBS->num_msgs; ++i) {
if (
(BBS->msgs[i] > BBS->lastseen)
&& ( (i == 0) || (BBS->msgs[i-1] <= BBS->lastseen) )
) {
/* new messages start here */
- do_template("start_of_new_msgs", NULL);
- StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#newmsgs\";\n");
+ do_template("start_of_new_msgs");
+ if (!go_to_the_very_end) {
+ StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#newmsgs\";\n");
+ }
}
if (BBS->msgs[i] > 0L) {
read_message(WC->WBuf, HKEY("view_message"), BBS->msgs[i], NULL, &Mime);
&& (BBS->msgs[i] <= BBS->lastseen)
) {
/* no new messages */
- do_template("no_new_msgs", NULL);
- StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#nonewmsgs\";\n");
+ do_template("no_new_msgs");
+ if (!go_to_the_very_end) {
+ StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#nonewmsgs\";\n");
+ }
}
}
}
/* Display the selecto-bar with the page numbers */
wc_printf("<div class=\"moreprompt\">");
+ if (seq == 2) {
+ wc_printf("<a name=\"end_of_msgs\">");
+ }
wc_printf(_("Go to page: "));
+ if (seq == 2) {
+ wc_printf("</a>");
+ }
first = 0;
last = BBS->num_pages - 1;
wc_printf("[");
}
else {
- wc_printf("<a href=\"readfwd?page=%d\">", i);
+ wc_printf("<a href=\"readfwd?go=");
+ urlescputs(ChrPtr(WC->CurRoom.name));
+ wc_printf("?page=%d\">", i);
wc_printf("<span class=\"moreprompt_link\">");
}
if (
wc_printf(_("Last"));
}
else {
- wc_printf("%d", i + 1); // change to one-based for display
+ wc_printf("%d", i + 1); /* change to one-based for display */
}
if (i == BBS->requested_page) {
wc_printf("]");
}
}
+ if (go_to_the_very_end) {
+ StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#end_of_msgs\";\n");
+ }
return(0);
}