X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Fblogview_renderer.c;fp=webcit%2Fblogview_renderer.c;h=9caccc9ca30523cbef17f39f005c46a9a16d7950;hp=b57d9d963c6629e4790587128c1c625d166737e4;hb=dbff3f19efefa1488dbd811d702069add21f264d;hpb=aeade41982c6c9a3e745a3b3c8262a3ec6952670 diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index b57d9d963..9caccc9ca 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -81,6 +81,7 @@ void blogpost_render(struct blogpost *bp, int with_comments) urlescputs(ChrPtr(WC->CurRoom.name)); wc_printf("#comments\">"); wc_printf(_("%d comments"), bp->num_msgs - 1); + wc_printf(" %d %s", bp->unread_oments, _("new")); wc_printf(" | %s", _("permalink")); @@ -197,8 +198,6 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat, } bp->msgs[bp->num_msgs++] = Msg->msgnum; if ((Msg->Flags & MSGFLAG_READ) != 0) { - syslog(LOG_DEBUG, "****************** unread %ld", Msg->msgnum); - bp->unread_oments++; } } @@ -246,15 +245,37 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper) /* Comments are shown if we are only viewing a single blog post */ with_comments = (BL->p != 0); - firstp = atoi(BSTR("firstp")); /* start reading at... */ - maxp = atoi(BSTR("maxp")); /* max posts to show... */ - if (maxp < 1) maxp = 5; /* default; move somewhere else? */ + firstp = ibstr("firstp"); /* start reading at... */ + maxp = ibstr("maxp"); /* max posts to show... */ + if (maxp < 1) maxp = 5; /* default; move somewhere else? */ + it = GetNewHashPos(BL->BLOG, 0); - //// bp->unread_oments++; + if ((BL->gotonext) && (BL->p == 0)) { + /* did we come here via gotonext? lets find out whether + * this blog has just one blogpost with new comments just display + * this one. + */ + struct blogpost *unread_bp = NULL; + int unread_count = 0; + while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) { + struct blogpost *one_bp = (struct blogpost *) Data; + if (one_bp->unread_oments > 0) { + unread_bp = one_bp; + unread_count++; + } + } + if (unread_count == 1) { + blogpost_render(unread_bp, 1); + + DeleteHashPos(&it); + return 0; + } + + RewindHashPos(BL->BLOG, it, 0); + } /* Iterate through the hash list and copy the data pointers into an array */ - it = GetNewHashPos(BL->BLOG, 0); while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) { if (num_blogposts >= num_blogposts_alloc) { if (num_blogposts_alloc == 0) {